In DB2 v6, I have a db2 column that is defined with the identity clause.
Following insert, I need a way to determine the identity value assigned
by DB2. The SQL Reference book gives the following example, using
VALUES and IDENTITY_VAL_LOCAL:
#1 CREATE TABLE EMPLOYEE
#1 (EMPNO INTEGER GENERATED ALWAYS AS IDENTITY,
#1 NAME CHAR(3 ),
#1 SALARY DECIMAL(5,2),
#1 DEPTNO SMALLINT);
#2 INSERT INTO EMPLOYEE
#2 VALUES ('Rupert',989.99,5 );
#3 VALUES IDENTITY_VAL_LOCAL()INTO :IVAR;
Now my question is:
If my batch process is running and has inserted a row (step 2),
then uses the VALUES statement (step 3) to get the value of the
inserted row, however during this time, an online user has
inserted a new row (between step 2 and 3 above), what value will
I get? the value from my insert, or from the online user insert?
Is this the best way to determine the identity of my inserted row?
Thanks, Dan T