Get Auto Inc ID

Forum related to MySQL

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
hsk
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 29.11.2009, 05:22
Location: Rio de Janeiro

Get Auto Inc ID

Post 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?
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post 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
Image
hsk
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 29.11.2009, 05:22
Location: Rio de Janeiro

Post by hsk »

hmm ok... I think I can use the ZQuery without ZUpdateSql
thx man ;)
Post Reply