dimanche 17 avril 2016

SQLite 'INSERT OR REPLACE INTO' incorrect behaviour

I'm using SQLite to store an id, uuid, value and a caught value.

I create the table with this command:

CREATE TABLE IF NOT EXISTS statz_fish_caught ('id' INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,'uuid' TEXT NOT NULL,'value' INTEGER NOT NULL,'caught' TEXT NOT NULL);

I use this command to insert (or replace) rows:

INSERT OR REPLACE INTO statz_fish_caught (uuid,value,caught) VALUES ('uuid comes here', a number here, 'a certain string').

When there is no row in the table it correct inserts a new row like this:

http://ift.tt/1r6VjXi

However, when I want to update the row with value 2, this happens:

http://ift.tt/1XDeDpk

It creates a new row, but I want original row to update with value 2.

I think I'm overseeing something, but I'm not sure what. Could you guys help me out?

Aucun commentaire:

Enregistrer un commentaire