Hi Dave, Wrap your update and select inside a transaction - the transaction is atomic in this regard and locks the table after the update and doesn't let it go until the commit/rollback. Others can read (they get the uncommitted values of course) but can't update. You will always get the latest uncommitted values from selects within the transaction.
Steve -----Original Message----- From: Ulrik Petersen [mailto:[EMAIL PROTECTED] Sent: 21 February 2005 10:21 To: sqlite-users@sqlite.org Subject: Re: [sqlite] Making a SEQUENCE? 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