Search code examples
phpsqliteinsert-update

Syntax error near on while using SQLITE on conflict clause


Here is my syntax where I am trying to update data if already exist but here I am not getting Why this error is coming up I am using SQLITE3.

Can anyone help me with my issue or can suggest me better solution if already on stack then I had tried that.

INSERT INTO triplets (`user`, `createtime`, `senderip`, `fromaddress`, `toaddress`, `blockextime`, `retrytime`,`recextime`) VALUES ("zulf", "152.228.249.250", "check@250.compilor.com", "test2@zulf.test", "1655878845", "1655879145", "1655893305", "1656138045") ON CONFLICT(`senderip`, `fromaddress`, `toaddress`) DO UPDATE SET deferred = deferred + 1 AND blockextime = CASE WHEN retrytime < 1658907917 THEN (1655879145) ELSE blockextime END AND retrytime = CASE WHEN retrytime < 1658907917 THEN (1655893305) ELSE retrytime END AND recextime = CASE WHEN retrytime < 1658907917 THEN (1656138045) ELSE recextime END WHERE senderip = "152.228.249.250" AND fromaddress = "check@250.compilor.com";

The error

Error: near "ON": syntax error

Solution

  • The problem is of Version there might be a chance that you are using the older version.