Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to get identity values after insert into a tbale with identity col

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
when a table 's primary key is identity ,how can i get the values after insert?
thanks a lot!
 
Hiya,
Just use the IDENTITY_VAL_LOCAL()function in a SET statement or subsequent insert statement; however you want to do it. Here's an example:

SET :HOSTVAR = IDENTITY_VAL_LOCAL()

Hope this helps!

Todd
IBM Certified Solutions Expert
 
If you're using DB2 7.2, you should probably know that the identity feature can lead to some serious concurrency problems. You may want to look at sequences instead -- they are much more conducive to high numbers of concurrent users.

-- Max
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top