我正在尝试使用 MySQL 在 Delphi 中使用 Select Into Outfile
命令:
dirfile:=pathProg+SaveDialog1.FileName+'.csv';
With dm.Query
do
begin
SQL.Clear;
SQL.Text:='SELECT * FROM tabel1 INTO OUTFILE :parfile';
Parameters.ParamByName('parfile').value:=dirfile;
ExecSQL;
end;
但是它不起作用,它返回一个错误:
you have error in your sql syntax check the manual that corresponds to your mariadb server version for the right syntakx to use near
有什么建议可以解决这个问题吗?
最佳答案
经过搜索后,发现您不能使用文件名的参数化值,它必须是字符串文字。在这种情况下,您必须手动构建 SQL 字符串,例如:
dirfile:=pathProg+SaveDialog1.FileName+'.csv';
with dm.Query do
begin
SQL.Text := 'SELECT * FROM tabel1 INTO OUTFILE ' + QuotedStr(dirfile);
ExecSQL;
end;
关于mysql - 德尔福: Select into outfile using parameter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42217076/