SQLite Forum

SELECT and RETURNING in one statement

I want to optimize my code a little bit. So far I was inserting always to trigger a hook for the rowid but I think it is not so smart because I will always write even if 90% of the entries are not changed. So I thought to test if they are equal. I think one lookup would be better than two.

CREATE TABLE IF NOT EXISTS translatables(id INTEGER NOT NULL UNIQUE, translationTextId TEXT PRIMARY KEY NOT NULL CHECK (translationTextId != ''))

I know the following code is not working but I think it shows my intention.

SELECT id FROM translatables WHERE translationTextId=?2
INSERT INTO translatables (id, translationTextId) (?1, ?2) ON CONFLICT(translationTextId) DO NOTHING RETURNING id;

So is there a way to archive that?
I found this [PostgreSql solution]( 
I looked into https://stackoverflow.com/questions/34708509/how-to-use-returning-with-on-conflict-in-postgresql) but to my understanding this is not working in Sqlite.

Later I use the ids to delete all not inserted or "updated" rows.