wood burning stoves 2.0*
The moose likes JDBC and the fly likes Retrieving Primary key Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Retrieving Primary key" Watch "Retrieving Primary key" New topic
Author

Retrieving Primary key

Suneesh Raman
Ranch Hand

Joined: Jun 13, 2002
Posts: 42
My table is in Sybase database . I am new to Sybase . I need to generate primary key using PrimaryKeyGenerator function. When I am inserting the data I need to get the primary key back and insert that value in some other table . Is there any API in java which retrieve the primary key at the time of inserting .

Thanks and regards
Suneesh
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
"PrimaryKeyGenerator" is a sybase function??
Suneesh Raman
Ranch Hand

Joined: Jun 13, 2002
Posts: 42
Yes
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
couldn't we get the key before actual insertion. we will insert the record ourselves after getting the key.

i mean first get the key from that function and store that key in some local variable of your code. then format the query, pass the same key and insert the record. this way you will have the whole record before insertion, including the primary key.

how it sounds??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Retrieving Primary key
 
Similar Threads
how to remove whitespace before inserting
getting Primary key when inserting
Getting primary keys
Inserting a record when the table has no primary key
how to retrieve the new ID of the auto_increment column