getlastid() in DB2

How cani get the (row)number of the last inserted row?

e.g. in MySQL: SELECT DISTINCT last_insert_id() from tableName;
in Sybase: select @@identity

Who is Participating?
waynezhuConnect With a Mentor Commented:
The DB2 equivalent is the IDENTITY_VAL_LOCAL() function.

" ...was first available in FixPak 3 of Version 7.1.
The IDENTITY_VAL_LOCAL function is a non-deterministic function that returns the most recently assigned value for an identity column, where the |assignment occurred as a result of a single row INSERT statement using a VALUES clause. The function has no input parameters."

For more detail, see the DB2 release notes.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.