If I have a table with an INTEGER PRIMARY KEY column, and I INSERT a new row into the table with a NULL binding to that column, sqlite will generate a unique value for me.
I know that I can use sqlite3_last_insert_rowid() to retrieve the value. However, in a multi-threaded environment, it's possible for another thread to do an INSERT before I get the first result. What's the best way to retrieve the rowid? The table is a simple name-value pairing. It would seem that uniqueness is not enforced for NULL names so I can't select the rowid based on the name. CREATE TABLE t (instance integer primary key, name text unique); INSERT INTO "t" VALUES(1,'foo'); INSERT INTO "t" VALUES(2,'new value'); INSERT INTO "t" VALUES(3,'newest value'); INSERT INTO "t" VALUES(4,NULL); INSERT INTO "t" VALUES(5,NULL); INSERT INTO "t" VALUES(6,''); INSERT INTO "t" VALUES(34567,'Description'); insert into t values(null,null); sqlite> select instance, quote(name) from t; 1|'foo' 2|'new value' 3|'newest value' 4|NULL 5|NULL 6|'' 34567|'Description' 34568|NULL sqlite> insert into metadata values(null,'Description'); Error: column name is not unique -Scott _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users