{"id":8496,"date":"2021-11-29T00:07:27","date_gmt":"2021-11-29T00:07:27","guid":{"rendered":"https:\/\/lgildv5i97.onrocket.site\/answers\/?post_type=question&#038;p=8496"},"modified":"2021-11-29T00:08:02","modified_gmt":"2021-11-29T00:08:02","slug":"appending-data-into-a-file-using-mysql-stored-procedure","status":"publish","type":"question","link":"https:\/\/computing.net\/answers\/dbase\/appending-data-into-a-file-using-mysql-stored-procedure\/1582.html","title":{"rendered":"Appending Data Into a File Using Mysql Stored Procedure"},"content":{"rendered":"<p>CREATE DEFINER=`root`@`localhost` PROCEDURE `sample_move`(IN FILEPATH VARCHAR(64))<br \/>\nBEGIN<\/p>\n<p>DECLARE VAR1 VARCHAR(200);<br \/>\nDECLARE VAR2 VARCHAR(200);<br \/>\nDECLARE VAR3 VARCHAR(200);<br \/>\nDECLARE VAR4 VARCHAR(200);<\/p>\n<p>SET SQL_SAFE_UPDATES=0;<\/p>\n<p>INSERT INTO TABLE_ARC (SELECT * FROM TAB1);<\/p>\n<p>SET VAR1=(SELECT ROW_COUNT());<\/p>\n<p>SET VAR2=(SELECT CONCAT( NOW() ,&#8217; &#8216; &#8216;ROWS INSERTED =&gt; &#8216;,VAR1));<\/p>\n<p>SELECT SQL_CALC_FOUND_ROWS * FROM TAB1;<\/p>\n<p>SET VAR3=(SELECT FOUND_ROWS());<\/p>\n<p>SET VAR4=(SELECT CONCAT( NOW() ,&#8217; &#8216;, &#8216;ROWS SELECTED =&gt; &#8216;,VAR3));<\/p>\n<p>SELECT COUNT(*) FROM TABLE_ARC;<\/p>\n<p>TRUNCATE TAB1;<\/p>\n<p>SELECT VAR4,VAR2 UNION<\/p>\n<p>SELECT VAR4,VAR2 INTO OUTFILE &#8216;f:\/myloV.TXT&#8217;<br \/>\nFIELDS TERMINATED BY &#8220;\\r\\n&#8221;<br \/>\nENCLOSED BY &#8216;&#8221;&#8216;<br \/>\nLINES TERMINATED BY &#8216;\\n&#8217;;<\/p>\n<p>COMMIT;<\/p>\n<p>END<\/p>\n<p>so when i am executing this procedure every time file is created.but i want append the data into the existing file..<\/p>\n<p>thanks in adwance<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"inline_featured_image":false,"iawp_total_views":6},"question-category":[51],"question_tags":[],"class_list":["post-8496","question","type-question","status-publish","hentry","question-category-dbase"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question\/8496","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question"}],"about":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/types\/question"}],"author":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/comments?post=8496"}],"wp:attachment":[{"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/media?parent=8496"}],"wp:term":[{"taxonomy":"question-category","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question-category?post=8496"},{"taxonomy":"question_tags","embeddable":true,"href":"https:\/\/computing.net\/answers\/wp-json\/wp\/v2\/question_tags?post=8496"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}