Stored procedure using "ORDER BY" and "auto-increment" columns
Posted: Tue 26 Jun 2007 17:38
If a MySQL table contains an auto-increment column, we are able to get it's new value after having done an "MyStoredProc.ApplyUpdates".
Example for an integer auto-increment column:
Now, if write into the stored procedure an "ORDER BY" at the end of the last SELECT that differs of the initial columns order, this features does not work anymore ! In fact, here the value of "MyStoredProc.FieldByName('auto-inc-column-name').AsInteger" is zero !!!
Maybe it's related to the "Update SQL" code generated in Delphi that must be re-generate after the "ORDER BY" has been added to the stored procedure ? No, I just tested that and it does not work either.
Any idea ?
Example for an integer auto-increment column:
Code: Select all
...
MyStoredProc.Insert;
...
MyConnection.StartTransaction;
MyStoredProc.ApplyUpdates;
// here we can access the value of the auto-increment field, even if the transaction has not been completed yet
// MyIntValue := MyStoredProc.FieldByName('auto-inc-column-name').AsInteger;
...
MyConnection.Commit;
Maybe it's related to the "Update SQL" code generated in Delphi that must be re-generate after the "ORDER BY" has been added to the stored procedure ? No, I just tested that and it does not work either.
Any idea ?