Stored procedure using "ORDER BY" and "auto-increment" columns

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jackfirst72
Posts: 8
Joined: Wed 02 Aug 2006 15:48

Stored procedure using "ORDER BY" and "auto-increment" columns

Post by jackfirst72 » 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:

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;
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 ?

Antaeus
Posts: 2098
Joined: Tue 14 Feb 2006 10:14

Post by Antaeus » Wed 27 Jun 2007 07:39

Please specify the following information:
- exact version of MyDAC. You can see it in the About sheet of TMyConnection Editor;
- exact version of MySQL server and MySQL client. You can see it in the Info sheet of TMyConnection Editor.

Post Reply