On 27 Dec 2010, at 7:41pm, Scott A Mintz wrote: > 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.
You can enforce the uniqueness yourself by declaring the column as UNIQUE or adding a UNIQUE INDEX. If that's not appropriate for your data, and you want to deal with the very unlikely situation of multiple users inserting the same names at roughly the same time, there's nothing you can do. You could use an IMMEDIATE TRANSACTION to lock the file, but that would inconvenience other users. Simon. _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users