Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) 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??
 
Happiness is not a goal ... it's a by-product of a life well lived - Eleanor Roosevelt. Tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!