zeos and auto increment

Forum related to all other 6.x versions of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

vinicius_vdb
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 12.01.2006, 18:40

zeos and auto increment

Postby vinicius_vdb » 12.01.2006, 18:53

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...

zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Postby zippo » 12.01.2006, 20:49

When inserting a row use the NULL value, example:

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

benp
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 26.01.2006, 12:15

Postby benp » 26.01.2006, 12:19

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

ssamayoa
Junior Boarder
Junior Boarder
Posts: 29
Joined: 14.01.2006, 19:06

Postby ssamayoa » 26.01.2006, 13:36

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.

zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Postby zippo » 27.01.2006, 09:06

To get the last inserted key: Select LAST_INSERT_ID()

benp
Fresh Boarder
Fresh Boarder
Posts: 2
Joined: 26.01.2006, 12:15

Postby benp » 30.01.2006, 17:59

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

zippo
Silver Boarder
Silver Boarder
Posts: 322
Joined: 12.10.2005, 18:01
Location: Slovenia

Postby zippo » 30.01.2006, 21:33

Think no, but you shoul consult some manuals (at leas PosGRe, Interbase and MsSQL

bravecobra
Junior Boarder
Junior Boarder
Posts: 29
Joined: 31.10.2005, 00:09
Location: Antwerp
Contact:

Postby bravecobra » 29.09.2006, 21:22

That's discussed here.


Return to “Other 6.x Versions”

Who is online

Users browsing this forum: No registered users and 1 guest