SQLite Forum

Returning and insert with conflict
Login
Hello

I have recurring pattern where I overwrite something and then remove the non updated and inserted rows. For that I get all rowids and then at the end use carray to delete the ones which are not in the array.

But what happens if I write?

INSERT OR IGNORE INTO my_table(foo) VALUES (?) RETURNING rowid
INSERT INTO my_table(foo) VALUES (?) ON CONFLICT DO NOTHING RETURNING rowid

Is the rowid returned if there was already an entry? To my understanding it will not. Maybe I could work around by adding a dummy column but it would be very handy.

Maybe a different syntax like would be better?

INSERT INTO my_table(foo) VALUES (?) ON CONFLICT DO RETURNING rowid

Best regards, Marco