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.