Given this table:
CREATE TABLE aTable (aCol TEXT UNIQUE, ...);
INSERT INTO aTable VALUES ( 'one', ... );
I need to duplicate rowid 1 and then change it
BEGIN;
INSERT INTO aTable SELECT * FROM aTable WHERE rowid = 1;
UPDATE aTable SET aCol = 'new unique value' WHERE rowid = 1;
COMMIT;
But that violates the UNIQUE constraint.
How can I retrieve the pre-transaction state of rowid 1?
Of course I could do a SELECT before the transaction, and bind its results to a prepared INSERT statement. I'm also aware of the following, but are there are other methods?
CREATE TEMP TABLE aTemp AS SELECT * FROM aTable WHERE rowid = 1;
...
DROP TABLE aTemp;
Updated
More context: aTable is a history table with normal order, later rows are later versions. However one row (rowid 1) is in progress and therefore not in the history. Thus rowid 1 must be updated to have the latest unique value.