I am developing a sql script that loads a .csv file stored in an S3 bucket into an RDS DB. The LOAD command works perfectly when not using CONCAT. I am using CONCAT to include variables with the statement. I believe the issue is with one or more of the clauses. I significantly shorted the fields for troubleshooting purposes. I have tried several different things, but can't seem to get the correct syntax.
set @s3intotemp = CONCAT('
LOAD DATA FROM S3 PREFIX "`',@workingdir, '`"
INTO TABLE `',@rndtable, '`
FIELDS TERMINATED BY ","
ESCAPED BY ""
ENCLOSED BY "\""
LINES TERMINATED BY "\n"
(@col1,
@col2)
SET customer=@col1,
firstname=@col2;
');
PREPARE stmt from @s3intotemp;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
I am getting the following error:
SQL Error: 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 '" (@col1, @col2 ) SET customer=@col1, firstname=@col2' at line 6