All Forums Database
przemb 2 posts Joined 06/09
15 Jun 2009
HOW TO return last inserted row ?

hi,i have a table with identity column being unique primary index.Is there a way to write a querry that will return a value of that column of my most recently inserted row?thanks.

smilever 45 posts Joined 10/07
15 Jun 2009

Pbar,The row with the max value for the column identity is the recently inserted row.select * from table_name where identity_col in (sel max(identity_col) from table_name);cheers:-)

Adeel Chaudhry 773 posts Joined 04/08
15 Jun 2009

Hello,With only having an IDENTITY column and no Insert/Update Date/Timestamp, you cannot get the latest inserted row.Smilever, please note IDENTITY does not generate values in sequence.HTH!Regards,Adeel

-- If you are stuck at something .... consider it an opportunity to think anew.

Jim Chapman 449 posts Joined 09/04
15 Jun 2009

The Teradata 12.0 release provides a new feature that enables the auto-generated key value (or all the columnds inserted row) to be returned to the application. The feature is available through the ODBC API. Usage information may be found in the "ODBC Driver for Teradata User Guide" publication.

smilever 45 posts Joined 10/07
22 Jun 2009

Adeel,Thanks a lot for the correction.I thought IDENTITY column generates values in sequence.Cheers:-)

20 Oct 2010

What particular feature in the ODBC API are you referring to for retrieving the IDENTITY value?

You must sign in to leave a comment.