Page 1 of 1

zeos and auto increment

Posted: 12.01.2006, 18:53
by vinicius_vdb
Hi,,,

I've used zeos with postgre, but i don't know how to use it with auto-increment, when i trie to append a new record by a TZquery the auto increment cod is not inserted, but when i execute a query (e.g. insert into...) all works ok..

thanks...

Posted: 12.01.2006, 20:49
by zippo
When inserting a row use the NULL value, example:

Insert Into CUSTOMER Values (NULL, "Customer name")

Posted: 26.01.2006, 12:19
by benp
Is it possible to get the value of the autoinc-field of the inserted recordset?
I've seen JDBC-database-connectors that offer this feature, and it's really nice!

Best regards, Benedikt

Posted: 26.01.2006, 13:36
by ssamayoa
This is the normal behaviour of C/S applications.
The application must SELECT the new insrted record to known wich fielsd where changed by pre-insert triggers and / or identity or auto inc fields.

Normally JDBC drivers can do this because them do the trick changing the SQL text adding RETURNING clause for those databases which supports it.

Better use sequence and get the value from database then put it on the field of your table before post.

Regards.

Posted: 27.01.2006, 09:06
by zippo
To get the last inserted key: Select LAST_INSERT_ID()

Posted: 30.01.2006, 17:59
by benp
Zippo, thanks a lot for this hint!

I just made a little test and it seems to me that you get even then to correct autoinc-number if there are 2 concurrent inserts running.
Does someone know whether the 'select LAST_INSERT_ID()' works with all databases?

cheers

Posted: 30.01.2006, 21:33
by zippo
Think no, but you shoul consult some manuals (at leas PosGRe, Interbase and MsSQL

Posted: 29.09.2006, 21:22
by bravecobra
That's discussed here.