I’m using TSQLConnection to connect to a remote MySql DB.
What i want is, to send several insert statements by once, instead of send one by one (this would be painfully slow).
But when i try to do it, i get an error from the server.
If i send only one statement, like :
mySQLConnection.execute('insert into table values (1,100)',nil);
It works. But if i send like this :
mySQLConnection.execute('insert into table values (1,100);insert into table values (2,200);insert into table values (3,300)',nil);
Server will raise an exception :
Project xxx.exe raised exception class TDBXError with message '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 ...
Any way to make it work ? On MySQL Workbench the same SQL statement with several inserts will work, but not on Delphi.
>Solution :
Each call to .execute() can only execute one query. If you want to insert multiple rows, put more than one list of values after VALUES.
mySQLConnection.execute('insert into table values (1,100), (2,200), (3,300)',nil);