use of serail key (auto increment)

pritam mungse

Greenhorn

Posts: 3

posted 14 years ago

Hi, the problem is when we have a serial key in the database, and when we insert a record in that table, how do we access it back. u don't know the value of hte serial key when u insert a record in the table, it is assigned by the database itself. the problem has some solution in the JDBC driver for the corresponding drivers. e.g. the informix JDBC driver gives specific api to get back the value of the serial field and this works fine in normal scenario. but when we are trying to use the weblogic connection pool, the method given by informix api are not avialable. ( the connection and statement classes are totaly different than the informix respectives, even though the driver specified is the informix JDBC driver.) can nyone tell me how to overcome this problem?

rgds,<br />pm.

Adam Hardy

Ranch Hand

Posts: 567

posted 14 years ago

You might have to write a stored procedure to return the last index. I don't know informix though, so I don't know what is possible.

I have seen things you people would not believe, attack ships on fire off the shoulder of Orion, c-beams sparkling in the dark near the Tennhauser Gate. All these moments will be lost in time, like tears in the rain.

Kel Walker

Greenhorn

Posts: 19

posted 14 years ago

This may or may not help. This is supported in JDBC 3.0. See the section named 'auto-generated keys' in this article.Getting upto date with JDBC

Originally posted by Kel Walker: This may or may not help. This is supported in JDBC 3.0...

Unfortunately, I haven't seen 1 JDBC 3.0 compliant driver yet. Oracle will increment the auto number (sequence) on a select using the sequence to obtain it's value, then use the value to write to the database. You can also handle the autonumber in a class by yourself. If you search the forum, it has been explained in detail in a previous thread. Jamie