On Mon, 29 Jul 2013 13:23:07 +0100
Simon Slavin <[email protected]> wrote:

> INSERT OR IGNORE a new row with the correct 'word' and a confidence
> of 0 
> UPDATE the row with that word to increment the confidence.
...
> If that solution doesn't work for you you might like to try first
> doing
> 
> UPDATE myTable SET ...
> 
> and then looking at the result of
> 
> sqlite3_changes()
> 
> to see whether it is 1 or not.  If it's zero, then you insert a new
> row, with a confidence of 1.

In the general case, if you UPDATE and find zero rows changed, and
then another process inserts the row (with count 1) before your INSERT,
then your INSERT will fail and confidence will remain at 1 when it
should be incremented to 2.  

        INSERT OR IGNORE a new row with confidence of 1 
        if( 0 == sqlite3_changes() )
                UPDATE set confidence = confidence +1

works in the presence of other updaters.  

--jkl
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to