Hi, i want to get the value of the last id insert in a table. How i can do this?
+1
A:
SELECT IDENTITY_VAL_LOCAL() AS VAL FROM SYSIBM.SYSDUMMY1
See docs.
Bill Karwin
2010-06-21 19:32:17
SYSDUMMY1? i can't find that table in the sysibm schema... :)
Enrique San Martín
2010-06-21 19:34:37
Are you being ironic? See http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0002369.html
Bill Karwin
2010-06-21 19:59:53
A:
Well the solution that i use is:
select id from NEW TABLE (insert into (val1, val2, ...) values ('lorem', 'ipsum', ...)
this get the id column from the last row inserted in the DB :)
Enrique San Martín
2010-06-21 22:01:56