Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving Primary key

 
Suneesh Raman
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"PrimaryKeyGenerator" is a sybase function??
 
Suneesh Raman
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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??
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic