Page 1 of 1

MySQL - multi-statement query

Posted: 23.06.2010, 05:47
by ManUtdFans
Hi,

Just wonder if I can put multi-SQL into the TZQuery?
I want to insert a record then fetch the last insert ID of the auto-incremented field.

eg.
BEGIN TREANSACTION;
INSERT INTO table1(empID, empName)
VALUES ('1234', 'John Smith');
SELECT LAST_INSERT_ID() As newID;
COMMIT;

do I call query1.Open or query1.ExecSQL?

Posted: 05.07.2010, 20:39
by mparak
Dear Man Supporter,

Use the ZSQLProcessor component instead and load the sql strings into the ZSQLProcessor.script
Make sure that every separate command ends with a ;
then ZSQLProcessor.Execute;

regards
M