View previous topic :: View next topic
|
Author |
Message |
Auryn
New User
Joined: 11 Jan 2006 Posts: 83 Location: Lower Saxony (DE)
|
|
|
|
I just have learned I can use the function IDENTITY_VAL_LOCAL to retrieve the last given value of a identity-column of a table.
And I have learned that this function only works in one UoW and that there must not be a commit or something like that before using the function.
But if I do a Insert in a SQL-PL-written stored procedure, may I check SQL-State and / ore -Code before retrieving the functions result?
May I code
Code: |
INSERT INTO tab (col2, col3)
VALUES (val2, val3);
IF SQLSTATE = '00000'
THEN
SET id_col = IDENTITY_VAL_LOCAL()
...
ELSE
...
END IF; |
Thanks for your help |
|
Back to top |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
you can always try and tell us the result
or write this :
Code: |
SELECT id_col into val1
FROM FINAL TABLE (INSERT INTO TB1 (col2, col3)
VALUES(val2, val3)) |
|
|
Back to top |
|
|
|