UCE Docs / sqlite_insert_id

Signature

u64 sqlite_insert_id(SQLite* db)

Parameters

db : pointer to an active SQLite connection
return value : last inserted rowid

Returns SQLite's last inserted rowid for the connection after an insert statement.

Example

SQLite* db = sqlite_connect("/tmp/doc-sqlite-insertid.db");
sqlite_query(db, "drop table if exists t");
sqlite_query(db, "create table t(id integer primary key autoincrement, v text)");
sqlite_query(db, "insert into t(v) values('x')");
print("new row id: ", sqlite_insert_id(db), "\n");
sqlite_disconnect(db);
Output
new row id: 1