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? -Dave -----Original Message----- From: Ulrik Petersen [mailto:[EMAIL PROTECTED] Sent: Monday, February 21, 2005 12:49 AM To: sqlite-users@sqlite.org Subject: Re: [sqlite] Making a SEQUENCE? Hi again, Brown, Dave wrote: >Is it possible to create the behaviour of a sequence with SQLite? > >I need to do something like this: > >[pseudocode] >var id = SELECT next_val FROM my_sequence; INSERT INTO table1 >VALUES(id, ...); INSERT INTO table2 VALUES(id, ...); > > > I forgot to say that if you want to insert the same ID into different tables, you'll have to create a single table that is an "id generator" using the method provided in the FAQ. For an example of how this could be done, see my Open Source text database project: http://emdros.org/preview/ You'll want to look in EMdF/sqliteemdfdb.cpp and EMdF/sqliteconn.cpp as well as their counterparts in include/ Cheers, Ulrik