• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 626
  • Last Modified:

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

bye,
   ton
0
iton
Asked:
iton
1 Solution
 
waynezhuCommented:
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.
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now