Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 加载数据本地填充语法错误_Mysql_Cron - Fatal编程技术网

Mysql 加载数据本地填充语法错误

Mysql 加载数据本地填充语法错误,mysql,cron,Mysql,Cron,使用EditLine包装器为debian linux gnu(x86_64)使用MySQL:MySQL版本14.14发行版5.6.24 我正在尝试cron一个加载数据的本地填充作业,以便每天运行两次。我很难对语法进行排序。目前,我有: #!/bin/bash mysql --user=dbuser --password="dbuserpassword" --database=DSDB --local-infile --execute " LOAD DATA LOCAL INFILE '/mn

使用EditLine包装器为debian linux gnu(x86_64)使用MySQL:MySQL版本14.14发行版5.6.24

我正在尝试cron一个加载数据的本地填充作业,以便每天运行两次。我很难对语法进行排序。目前,我有:

#!/bin/bash

mysql --user=dbuser --password="dbuserpassword" --database=DSDB --local-infile --execute "

LOAD DATA LOCAL INFILE '/mnt/hqsccm/TSReport.CSV'
INTO TABLE temptable
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n'
(@compname,@imgdate,@imgname,@imgsttime,@imgendtime,@tottime,@engname,@engemail) set ComputerName=@compname,ImagingDate=@imgdate,ImageName=@imgname,ImageSTartTime=@imgsttime,ImageEndTime=@imgendtime,TotalTime=@tottime,EngineerName=@engname,EngineerEmail=@engemail;

TRUNCATE HQSCCMmachines;

INSERT INTO HQSCCMmachines (ComputerName,ImagingDate,ImageName,ImageSTartTime,ImageEndTime,TotalTime,EngineerName,EngineerEmail)
SELECT (ComputerName,ImagingDate,ImageName,ImageSTartTime,ImageEndTime,TotalTime,EngineerName,EngineerEmail)
  FROM temptable

TRUNCATE temptable;
"
我一直在想:

ERROR 1064 (42000) at line 11: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'temptable' at line 5
帮助?

这应该有效(如果存在文件和表)-


你能发布你的CSV文件的前2-3行吗?
TSReport.CSV
?我想问题很简单,你需要在第二行到最后一行代码的
中添加一个分号。现在我得到了“第10行的错误1241(21000):操作数应该包含1列”我取出了变量。
    LOAD DATA LOCAL INFILE '/mnt/hqsccm/TSReport.CSV'
INTO TABLE temptable
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\r\n'
(@compname,@imgdate,@imgname,@imgsttime,@imgendtime,@tottime,@engname,@engemail) set ComputerName=@compname,ImagingDate=@imgdate,ImageName=@imgname,ImageSTartTime=@imgsttime,ImageEndTime=@imgendtime,TotalTime=@tottime,EngineerName=@engname,EngineerEmail=@engemail;

TRUNCATE HQSCCMmachines;

INSERT INTO HQSCCMmachines (ComputerName,ImagingDate,ImageName,ImageSTartTime,ImageEndTime,TotalTime,EngineerName,EngineerEmail)
SELECT ComputerName,ImagingDate,ImageName,ImageSTartTime,ImageEndTime,TotalTime,EngineerName,EngineerEmail
  FROM temptable;

TRUNCATE temptable;