computing
  • 0

Appending Data Into a File Using Mysql Stored Procedure

  • 0

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

Share