Navigation:  NexusDB Guide > SQL Reference > SQL Functions > Numeric Value Functions >

LastAutoinc Function

Previous pageReturn to chapter overviewNext page

NexusDB V3 Manual

LastAutoinc Function

button_main button_prev button_next

NexusDB Manual V3 > SQL Reference > SQL Functions > Numeric Value Functions

Syntax

 

<lastautoinc function> ::=

 

 

|

 

LASTAUTOINC

IDENTITY

 

 

Notes

 

§

The LASTAUTOINC function returns the most recent AutoInc value generated by the current SQL session.

 

§

The data type of the result is DWORD.

 

§

If no AutoInc value has been generated during the current SQL session, then the result is null.

 

§

The LASTAUTOINC function should always be executed inside a transaction when the result is used for assignments.

 

§

The IDENTITY keyword, which is a synonym for the LASTAUTOINC function, is deprecated in V2 and may be deleted in a future version of NexusDB SQL.

 

 

Examples

 

1)

Assuming master.masterID is an AUTOINC column, the following example first inserts a new row into master, which causes the AUTOINC column to be incremented, and then inserts a new row into the detail table using the LASTAUTOINC function to assign the last generated AutoInc value to the detail.masterID column:

 

      START TRANSACTION;

      INSERT INTO master ( masterID ) VALUES ( 100 );

      INSERT INTO detail ( masterID, detailID ) VALUES ( LASTAUTOINC, 1 );

      COMMIT;

 

 


Conformance

 

NexusDB extensions

-

LASTAUTOINC function

 

© Nexus Database Systems Pty Ltd.

nexus_logo