mysql - 德尔福: Select into outfile using parameter

标签 mysql delphi mariadb

我正在尝试使用 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/

相关文章:

php - Mysqli_multi_query 是否提高性能

mysql - postgres - 修改 xml(MySql UpdateXml 替代)

php - mysql月度报告

delphi - Delphi拼写检查器

php - 无法在 Linux 上启动 mysql(错误 2002 HY000)

mysql - 使用 innodb_buffer_pool 和查询缓存

forms - 应用程序何时显示在任务栏上?

delphi - 将表单的第二个实例绑定(bind)到数据模块的第二个实例?

mysql - 自动转换查询结果中每个日期列的日期格式的函数?

mysql - 用于删除列上的部分 URL 的 SQL 语句