Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL + LOAD DATA INFILE + variable path

Tags:

mysql

Below is my code code and is wrong for MySQL. @Path not be allowed variable with syntax "LOAD DATA INFILE" and I don't know exactly path + filename.

Do you have any idea how to solve this issue?

SET @Path = CONCAT(sysf_Get_Options('DRIVE'),sysf_Get_Options('PATH_SAP_FILE'),'277.txt');

LOAD DATA INFILE @Path
  INTO TABLE SAP_TMP 
  LINES TERMINATED BY '\r\n'
  (@var1)
  SET txt = SP_INSERT_ROW_CONTRACTS(@var1)
;
like image 613
RomanNTA Avatar asked Feb 18 '26 01:02

RomanNTA


1 Answers

http://dev.mysql.com/doc/refman/5.6/en/load-data.html says:

The file name must be given as a literal string.

So you can't use a variable for the path. You have to code a literal, quoted string into the statement before it is parsed.

like image 76
Bill Karwin Avatar answered Feb 20 '26 17:02

Bill Karwin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!