Graham Holden wrote: > insert or ignore into Servers values ( 'MyServer', 12345, ( select > count (*) from Servers ) ) > > is the "count (*)" guaranteed to be the count before the insert?
Yes. But if any row was ever deleted, that value might alread by used. You could make serverIdx autoincrementing by making it the INTEGER PRIMARY KEY. If you do not want to change the primary key, you can get a value that is guaranteed to be unused with max(): INSERT OR IGNORE INTO Servers VALUES ('MyServer', 12345, (SELECT ifnull(max(serverIdx), 0) + 1 FROM Servers)); Regards, Clemens _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users