Natural function
AdaBase.Statement.Base.[STMT].last_insert_id ()

This function returns the ID of the last inserted row as a result of a prepared statement execute. If the driver does not support the concept of auto-increment fields, the return value will always be zero.

For the PostgreSQL driver, if the query is in the form of INSERT INTO .. RETURNING, then the last_insert_id comes directly from the result set of this INSERT statement. If no RETURNING clause is present, the last_insert_id is the result of "SELECT lastval()" which is normally accurate, but not in every case.

See prepare select for a usage example.

[STMT] is "MySQL.MySQL_statement", "PostgreSQL.PostgreSQL_statement", or "SQLite.SQLite_statement"

See Also