Hi, I have the following problem: I have data where two independent values need to be unique. I'm using one (id) as the primary key, and the other (let's call it k) should just cause insertion or updating to fail if it already exists in another row with a different id in the table.
Furthermore, I'd like this to be free from race conditions :) If I just use two different UNIQUE indexes, doing a "INSERT OR REPLACE" will cause another row that has the same k to be replaced, instead of failing to update due to the differing id. I suppose this is entirely logical, but it's not what I'd like to achieve :) So, bottom line, is there a way to insert or replace a row so that first the id constraint is observed (replacing a previous row with the same id), and then the k constraint is verified (failing to replace if k is already present in the table)? I'm ok with doing some multi-step thing, perhaps first trying UPDATE and then INSERT, but I'm not sure what would be most efficient, and I'm also not sure how to prevent racing when checking for k… Thanks in advance for any insights! Wout. _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users