On Friday, 22 February, 2019 09:08, Constantine Yannakopoulos 
<alfasud...@gmail.com>:

> 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?

I suppose you could add a field to the table and set that field according to 
whether the UPSERT UP'ed or SERT'ed ... then go look at that field ... 
Personally, I should think it would be simpler to simply devolve the single 
declarative UPSERT into its component parts are merely watch what is happening 
as it goes along ...

You are doing the equivalent of asking whether there is a way to tell if 
"create table if not exists xxxx" created the table or not, which is a 
ridiculous question.  After the execution of the statement the table exists.  
If you care whether the statement created the table or not then your issue is 
that you failed to understand and have chosen the statement incorrectly.

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.




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

Reply via email to