appending data into a file using mysql stored procedure

October 13, 2015 at 23:58:53
Specs: Windows 7
CREATE DEFINER=`root`@`localhost` PROCEDURE `sample_move`(IN FILEPATH VARCHAR(64))
BEGIN

DECLARE VAR1 VARCHAR(200);
DECLARE VAR2 VARCHAR(200);
DECLARE VAR3 VARCHAR(200);
DECLARE VAR4 VARCHAR(200);

SET SQL_SAFE_UPDATES=0;

INSERT INTO TABLE_ARC (SELECT * FROM TAB1);

SET VAR1=(SELECT ROW_COUNT());

SET VAR2=(SELECT CONCAT( NOW() ,' ' 'ROWS INSERTED => ',VAR1));

SELECT SQL_CALC_FOUND_ROWS * FROM TAB1;

SET VAR3=(SELECT FOUND_ROWS());

SET VAR4=(SELECT CONCAT( NOW() ,' ', 'ROWS SELECTED => ',VAR3));

SELECT COUNT(*) FROM TABLE_ARC;

TRUNCATE TAB1;

SELECT VAR4,VAR2 UNION

SELECT VAR4,VAR2 INTO OUTFILE 'f:/myloV.TXT'
FIELDS TERMINATED BY "\r\n"
ENCLOSED BY '"'
LINES TERMINATED BY '\n';

COMMIT;


END

so when i am executing this procedure every time file is created.but i want append the data into the existing file..

thanks in adwance


See More: appending data into a file using mysql stored procedure

Report •


#1
October 14, 2015 at 00:55:43
Use the MySQL "TEE" command: http://code.openark.org/blog/mysql/...

Report •

#2
October 14, 2015 at 01:16:21
ok.TEE command is used in mysql client. so how would i use tee command in stored procedure

Report •

#3
October 14, 2015 at 01:57:56
Sorry, I missed the Stored Procedure requirement.

I think if I were doing this sort of logging I would write the log information to another table. You could then read directly from this table or else dump it to a text file as required. The only other approach that I can think of would be to output to a temporary file and then use a UDF to append this temporary file to the log file; but that doesn't seem to be a very efficient approach.

message edited by ijack


Report •

Related Solutions

#4
October 14, 2015 at 03:49:54
can u send me how to write log information to another table for my example program

message edited by venkii


Report •

#5
October 14, 2015 at 06:09:39
I suggest that you read some SQL tutorials if you want to discover how to write information to a database table. Sorry, I'm happy to point to a possible answer but I'm not going to do the work for you.

Report •

#6
October 14, 2015 at 22:49:52
ok thanks for ur response..and is there possible to append my data into a existing file through stored procedure..

Report •


Ask Question