I have a question about sqlite.
Assuming I created a table:
CREATE TABLE GOODS(ID TEXT PRIMARY KEY NOT NULL, TYPE TEXT, VERSION INTEGER)
Then after a while I want to use 'insert or replace' like this:
insert or replace into GOODS(ID, TYPE,VERSION) values ('chrome_id', 'chrome', 15);
But I want this query to 'replace' iff old.VERSION < new.VERSION.
How can I do that?
Do I need to use 2 queries (it should looks like this:) ?
1. get row
if(row.VERSION < myVersion){
2. insert or replace ...
}
I heard about trigger but I do think this the solution. thx