On Dec 30, 2013, at 1:48 PM, Richard Hipp <d...@sqlite.org> wrote:

> One example:
> 
>   sqlite3_exec("INSERT OR IGNORE INTO ....;");
>   if( sqlite3_changes()==0 ){
>     sqlite3_exec("UPDATE ...");
>   }

This is rather error prone and may results in, well, unexpected results.

How to lose your data in two easy steps:

(1) IGNORE is triggers by a constraint other than unique resulting in 
sqlite3_changes()==0.
(2) The UPDATE silently updates, well, nothing at all.
(3) There is no step 3, nor any data.

I would personally not rely on such construct.

What SQLite needs is a proper MERGE statement.

 

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

Reply via email to