Hi Dave,

Brown, Dave wrote:

I read that faq, but I dont see how that solves this yet. I understand how
the insert will autoincrement, but I need to do "increment + return new
value" in one atomic operation. If I just issue an insert, then try to use
the new value from that table, I'm not guaranteed that someone else hasn't
also incremented it further before I got to it.

Do you see what I mean?


Yes. If you are using SQLite 2.8.X, then use:

int sqlite_last_insert_rowid(sqlite*);

http://www.sqlite.org/c_interface.html   Section 3.0


If you are using SQLite 3, then there is an analogous function:

http://www.sqlite.org/capi3ref.html#sqlite3_last_insert_rowid

/Ulrik

--
Ulrik Petersen, MA, B.Sc.
University of Aalborg, Denmark
Homepage: http://ulrikp.org




Reply via email to