Dominique Devienne wrote: > sqlite> select * from t; > 1|one bis > 2|two > sqlite> insert or replace into t (name) values ('one bis'); > sqlite> select * from t; > 2|two > 3|one bis > > In the session above, we can see that an insert or replace w/o an id (the PK) > value, > results in the id changing in the table, which is not what we'd like. > > Is that normal or expected?
REPLACE always deletes the old row, if it exists. This is documented. > Is there a SQL way (one statement ideally) to achieve what we'd like? An INSERT OR UPDATE (or MERGE) statement does not exist in SQLite. Just try the UPDATE, and if the number of affected rows is zero, do the INSERT. Regards, Clemens _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users