I’m using SQLite database.
I want make an insert and get the field ID (autogenerated) of this insert.
The field ID is an autoincrement key.
I’m using the statement
SELECT last_insert_rowid();
and this works fine.
The problem is when I have many concurrent insert into the table: in this case it possible it returns me an ID associated to another insert (not my insert).
What can I do, for making the operation in autonoumus manner?
From the SQLite documentation;
So, as long as you’re calling the select on the same connection right after you did the insert, other simultaneous users are entirely independent and won’t cause the returned value to be wrong.