Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sybase Advantage New AutoInc after SQL Insert

Anyone knows how to retrieve a new AutoInc that gets written after an ODBC INSERT? Is there a variable I have access to just like SQL Server? Right now, I'm using :

SELECT MAX(myautoincfield) AS mylastkey FROM anytable 

in order to retrieve my new key.

like image 998
user1034808 Avatar asked Aug 14 '26 18:08

user1034808


1 Answers

The scalar function LastAutoinc can retrieve it efficiently:

select LastAutoinc(statement) as mylastkey from system.iota;
like image 159
Mark Wilkins Avatar answered Aug 17 '26 23:08

Mark Wilkins