我正在使用两个准备好的语句(@aux1
和@aux2
)将一些数据复制到文本文件中的过程。然后复制信息的表,删除所有行。
问题是,当我使用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
还是在每个查询中仅接受此语句之一。
怎么了?
我正在使用一个使用两个准备好的语句(@ aux1和@ aux2)将一些数据复制到文本文件中的过程。然后将信息复制到的表中,删除所有行。 ...