user157629:
私は、テキストファイルにコピーし、いくつかのデータが2つのプリペアドステートメント(使用していることを手順に取り組んでいる@aux1
と@aux2
)を。その後、情報がコピーされたテーブルには、GETが削除されたことのすべての行です。
問題は、私が使用してプロシージャを実行したときということですcall copyIntoFile()
、私はエラーを取得します。
手順
delimiter !!
drop procedure if exists copyIntoFile !!
create procedure copyIntoFile()
begin
declare path varchar(255);
set path = concat("'C:/ProgramData/MySQL/MySQL Server 5.7/Uploads/", curdate(), ".txt'");
set @aux1 = concat("select * from movie_modification where modified = true into outfile ", path,
" fields terminated by ';' lines starting by 'Edit: ' lines terminated by '\n';");
prepare stmt1 from @aux1;
execute stmt1;
deallocate prepare stmt1;
set @aux2 = concat("select * from movie_modification where modified = false into outfile ", path,
" fields terminated by ';' lines starting by 'New: ' lines terminated by '\n';");
prepare stmt2 from @aux2;
execute stmt2;
deallocate prepare stmt2;
delete from movie_modification;
end !!
delimiter ;
ERROR(プロシージャを実行します)
エラーコード:1064あなたは、あなたのSQL構文でエラーが発生しています。右の構文についてはMySQLサーバのバージョンに対応するが、1行目で「」近い「で終わる行を」を使用すること取扱説明書をご確認ください
あなたが見ることができるように、エラーが発生した付近でlines terminated by
(1行目)。私が使用できるのであれば、今、私は思ったんだけどlines terminated by
後lines starting by
またはこの文のひとつは、各クエリに受け入れられた場合。
どうしましたか?
GMB:
私はあなたがこれを交換する必要があると思います。
select ...
into outfile ...
fields terminated by ';' lines starting by 'Edit: ' lines terminated by '\n'
と:
select ...
into outfile ...
fields terminated by ';' lines starting by 'Edit: ' terminated by '\n'
それは次のとおりです。lines
キーワードは繰り返されるべきではありません。