Solved

getlastid() in DB2

Posted on 2002-03-04
1
607 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now