A SQL::TableInfo object.
- ResultAny Type
The last inserted identity, if available.
Returns the last inserted identity for a specific table (where possible) after executing an INSERT statement.
The LastInsertedIdentity() method retrieves the last identity value generated for an INSERT on the currently open connection.
This is current connection specific for most databases. For databases that use sequences to maintain identity (such as Oracle), the sequence may not be correct after the transaction has been completed.
For databases that use sequences to generate identities <TableInfo> is a required parameter. It must include an identity column in its definition. That column must specify the sequence name to be used.
Cn.CallResult.LastInsertedIdentity is always preferable to Cn.LastInsertedIdentity() after an INSERT is executed. *Cn.CallResult.LastInsertedIdentity will contain the identity for the record that was just inserted after executing an INSERT statement while the SQL::Connection LastInsertedIdentity() method returns the last inserted identity for the current open table.
dim cn as sql::Connection dim insert as c =<<%sql% INSERT INTO employees (FirstName,LastName,HireDate) VALUES (:Firstname,:Lastname,:HireDate); %sql% dim args as sql::Arguments args.set("Firstname","Alma") args.set("Lastname","Vasquez") args.set("HireDate",date()) dim id as N = 0 if (cn.open("::Name::mysql_northwind")) then if (cn.execute(insert,args)) then ' insert success id = cn.LastInsertedIdentity() else ' insert failed end if cn.close() else ' could not open connection end if