Return the last inserted row primary key
#include <qdb/qdb.h> uint64_t qdb_last_insert_rowid( qdb_hdt_t *hdl, qdb_result_t *result );
Each entry in a QDB table has a unique integer key called the row ID. The row ID is always available as an undeclared column named ROWID, OID, or _ROWID_. If the table has a column of type INTEGER PRIMARY KEY, then that column is another an alias for the rowid.
This function returns the row ID of the last INSERT. It first looks in result (if the QDB_OPTION_LAST_INSERT_ROWID option has been set by qdb_setoption()), returning the information for the statement that produced the result. If result is NULL, or QDB_OPTION_LAST_INSERT_ROWID is off, the function queries the database handle hdl and returns the information about the last executed statement.
If this function returns 0, check errno to make sure that it is EOK, indicating that no rows were inserted (you should set errno to 0 before calling this function if you want to distinguish between an error and 0 rows). If errno is set, then there was an error with the request.
If an INSERT occurs within a trigger, then the rowid of the inserted row is returned by this function as long as the trigger is running. But once the trigger terminates, the value returned by this routine reverts to the last value inserted before the trigger fired.