Page 1 of 1

Get Auto Inc ID

Posted: 29.11.2009, 05:37
by hsk
Hi there,

I'm back to programming software to pc using D2009 and mysql. I started using MyDAC to access the data base. It is good, but isn’t free. So I kept looking for and I found the Zeos. I installed and made a simple example, the next step was get the value of ID auto increment field. I read some solutions using last_insert_id, but in my studies I found into event "AfterInsertSQLStament" on ZUpdateSQL a parameter "out UpdateAutoIncField: Boolean" and I put the parameter to true into procedure, after that the value of field ID already fill automatically.

So, as I found nothing about this method to get the autoincfield, I have a question about this. Is ok to use it to get the value of this kind of fields?

Posted: 02.12.2009, 21:20
by mdaems
Hi hsk,

I'm not a really experienced zeoslib user myself. I didn't use ZUpdateSql myself up to now. Do you need the component because your queries are too complex to be updated by the TZQuery directly?

If not, there's a really easy way to insert data an a TZQuery and fetch the autoincrement value with mysql. Just Append a row to the dataset, fill the non-autoincrement fields and when it's posted to the database, the autoincrement fields are automatically filled by the Last_insert_id.

If you do need ZUpdateSQL, somebody else will have to reply, I'm afraid.

Mark

Posted: 08.12.2009, 17:27
by hsk
hmm ok... I think I can use the ZQuery without ZUpdateSql
thx man ;)