The mission statement of the upsert is to fulfil the assertion that a row 
exists and the desired change has been recorded therein, while hiding the 
details (new row inserted or old row updated) from the caller. Why do you think 
you need this information? As already suggested, use a transaction to retrieve 
the row; update if found and insert if not.



-----Original Message-----
From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On 
Behalf Of Constantine Yannakopoulos
Sent: Freitag, 22. Februar 2019 17:08
To: SQLite mailing list <sqlite-users@mailinglists.sqlite.org>
Subject: [EXTERNAL] [sqlite] Find if an upsert operation did an insert or an 
update.

Hello,

I would like to find whether an upsert operation actually did an insert or an 
update, preferably without having to execute extra SQL statements before or 
after it. I thought of using last_insert_rowid() before and after the upsert 
and check if the result has changed but while this seems to work for normal 
tables it will not work for WITHOUT ROWID tables. Is there another way that 
works consistently both with tables with or without rowid?

Best regards,

Constantine
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


___________________________________________
 Gunter Hick | Software Engineer | Scientific Games International GmbH | 
Klitschgasse 2-4, A-1130 Vienna | FN 157284 a, HG Wien, DVR: 0430013 | (O) +43 
1 80100 - 0

May be privileged. May be confidential. Please delete if not the addressee.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to