Q
Problem solve Get help with specific problems with your technologies, process and projects.

Using VALUES IDENTITY_VAL_LOCAL()

When using the "VALUES IDENTITY_VAL_LOCAL()" statement immediately following an insertion into a table with an identity column, how can I be sure I am receiving back the value just inserted for my transaction and not that of another user who may have also attempted an insert?

Well, the short answer is because that is the way IBM coded the function to work. The IDENTITY_VAL_LOCAL() function will return the last inserted identity value. Each INSERT statement involving an IDENTITY column causes the identity value to be copied into connection-specific storage in DB2. Thus, the most recent identity value is used for a connection, regardless of what is happening with other concurrent user connections.

Be sure to read the information in the DB2 SQL Reference manual for the IDENTITY_VAL_LOCAL() function thoroughly to understand what will be returned and why.

Dig Deeper on IBM DB2 management

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchBusinessAnalytics

SearchAWS

SearchContentManagement

SearchOracle

SearchSAP

SearchSQLServer

Close