I saw this post MySQL load data: This command is not supported in the prepared statement protocol yet and didn't get it quite right so i'm posting my own code.
I've got monthly tables starting in 200601 and i need to import fixed width text files into them (these are also monthly, i.e, 200601.txt; 200602.txt; ...; 201710.txt).
BEGIN
DECLARE count INT Default 200600;
simple_loop: LOOP
SET @a := count + 1;
SET @statement = CONCAT('
LOAD DATA LOCAL INFILE
','"D:/path/2006/',@a,'.txt"','
INTO TABLE
database.',@a,'
(@ROW)
SET proc = trim(substr(@row,1,6)),
product = trim(substr(@row,7,4)),
subp = trim(substr(@row,11,4)),
cont = trim(substr(@row,15,20)),
client = trim(substr(@row,35,8)),
sis = trim(substr(@row,43,3)),
#[and a lot more]
');
PREPARE stmt FROM @statement;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
SET count = count + 1;
IF count=200612 THEN
LEAVE simple_loop;
END IF;
END LOOP simple_loop;
END
Then I get
Error Code: 1295. This command is not supported in the prepared statement protocol yet.
at the line
LOAD DATA LOCAL INFILE
Is there any way around that? A software maybe?