Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

getlastid() in DB2

Posted on 2002-03-04
1
611 Views
Last Modified: 2012-06-22
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
Comment
Question by:iton
1 Comment
 
LVL 7

Accepted Solution

by:
waynezhu earned 90 total points
ID: 6875977
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

789 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question