On Tue, May 26, 2009 at 5:17 PM, Nikolaus Rath <nikol...@rath.org> wrote: > Hello, > > How can I determine the rowid of the last insert if I am accessing the > db from different threads? If I understand correctly, > last_insert_rowid() won't work reliably in this case.
It should work if you do: BEGIN INSERT ... last_insert_rowid() END If you don't do this then last_insert_rowid() could refer to an insert happening in other thred: <thread 1> INSERT ... <thread 2> INSERT ... <thread 1> last_insert_rowid() <thread 2> last_insert_rowid() <...> Also (not really sure as I avoid threads) I believe it will work if each thread has it's own db handle, but don't know what will happen you use the shared cache feature. Regards, ~Nuno Lucas > > I can't believe that I really have to do a SELECT on the data that I > just INSERTed only to get the rowid... > > > Thanks, > > -Nikolaus > > -- > »Time flies like an arrow, fruit flies like a Banana.« > > PGP fingerprint: 5B93 61F8 4EA2 E279 ABF6 02CF A9AD B7F8 AE4E 425C > > _______________________________________________ > sqlite-users mailing list > sqlite-users@sqlite.org > http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users > _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users