MySQL Forums :: General :: Procedure is not working


Advanced Search

Procedure is not working
Posted by: Volker Bornhake ()
Date: April 17, 2012 05:33AM

CREATE PROCEDURE `remos_webapp_testdb`.`Daten_Sicherung` ()
BEGIN
DECLARE done INT DEFAULT 0;
DECLARE v_ID INT DEFAULT 0;
DECLARE v_Table_Name char(50);
DECLARE v_Datei char(100);
DECLARE cur1 CURSOR FOR Select Table_name from information_schema.tables where table_schema='remos_webapp_testdb';
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;

Select count(Table_name) INTO v_ID From information_schema.tables Where table_schema='remos_webapp_testdb';

OPEN cur1;

REPEAT

FETCH cur1 INTO v_Table_Name;

Set v_Datei = CONCAT('/Users/vbornhake/Downloads/',"'",v_Table_Name,"'",'.csv');
SELECT * FROM v_Table_Name
INTO OUTFILE v_Datei
FIELDS TERMINATED BY ';'
LINES TERMINATED BY '\n';

UNTIL done END REPEAT;

CLOSE cur1;

END;

I will fetch all tables from information_schema to one table_schema and then I will create for each table one outputfile with the name of the table. Sample: Table=test outputfile=test.csv. But this is not working I got failure on "INTO OUTFILE v_Datei. Please help.

regards Volker

Options: ReplyQuote


Subject Written By Posted
Procedure is not working Volker Bornhake 04/17/2012 05:33AM
Re: Procedure is not working irek kordirko 04/17/2012 09:03AM
Re: Procedure is not working Rick James 04/19/2012 08:17PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.