If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Managing identity column in java

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-20-04, 12:58
luca200 luca200 is offline
Registered User
 
Join Date: Oct 2002
Location: Italy
Posts: 9
Managing identity column in java

How can I retrieve the identity column value generated by DB2 when I make an INSERT using JDBC?
I see IBM doc talking about VALUES IDENTITY_VALUE_LOCAL INTO :host-variable, but... I don't see how to translate the concept of 'host-variable' in java

Thanks
Reply With Quote
  #2 (permalink)  
Old 07-20-04, 14:39
J Petruk J Petruk is offline
Registered User
 
Join Date: Mar 2004
Location: Toronto, ON, Canada
Posts: 513
Quote:
Originally Posted by luca200
How can I retrieve the identity column value generated by DB2 when I make an INSERT using JDBC?
I see IBM doc talking about VALUES IDENTITY_VALUE_LOCAL INTO :host-variable, but... I don't see how to translate the concept of 'host-variable' in java

Thanks
You can use that in java, just take off the "INTO :hostvariable", issue it as a regular Statement and it will be returned in the ResultSet.

There's also a new method getGeneratedKeys() that was introduced in JDBC, for use with Statement or PreparedStatement objects. I'm not sure if DB2 conforms to it yet, though, might want to give it a try. It returns a ResultSet.
__________________
--
Jonathan Petruk
DB2 Database Consultant
Reply With Quote
  #3 (permalink)  
Old 07-20-04, 14:53
luca200 luca200 is offline
Registered User
 
Join Date: Oct 2002
Location: Italy
Posts: 9
Quote:
Originally Posted by J Petruk
You can use that in java, just take off the "INTO :hostvariable", issue it as a regular Statement and it will be returned in the ResultSet.
Thank you, I'll try
Quote:
Originally Posted by J Petruk
There's also a new method getGeneratedKeys() that was introduced in JDBC, for use with Statement or PreparedStatement objects. I'm not sure if DB2 conforms to it yet, though, might want to give it a try. It returns a ResultSet.
I found it in docs, but I can't use it because I have Java 1.3.1....

thanks anyway :-)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On