0

I'm trying to use SQLite's upsert syntax as described in their documentation

However I get the following error, in both WebSql (SQLite v3.41.2) and SQLite on Android (SQLite v3.40.0)

could not prepare statement (1 near \"DO\": syntax error)

The error suggests this syntax isn't supported but UPSERT support was added in 3.24.0.

I also tested the exact query I'm using on dbFiddle and it runs fine,

I'm lost!

/edit

The query was in the dbFiddle, but for clarity, I'm using Ionic with the SQLite plugin. Given the following table

CREATE TABLE Drawings(
id INTEGER NOT NULL UNIQUE, 
title TEXT NOT NULL, 
fileId TEXT NOT NULL, 
documentUrl TEXT,
PRIMARY KEY(id))

Running the following query

INSERT INTO Drawings(id, title, fileId, documentURL) 
VALUES(1,'asd','asd123123asd','qwefdfg') 
ON CONFLICT (id) DO UPDATE SET title = excluded.title, fileId = excluded.fileId, documentURL = excluded.documentUrl

Yields the error

could not prepare statement (1 near \"DO\": syntax error)

Basically it seems that the ON CONFLICT DO UPDATE isn't supported but that was added in SQLite 3.24.0 and I'm testing in 3.41.2 (WebSQL) and 3.40.0 (Android API 34)

2
  • Please show us your query. How else can we know whats wrong with it. Commented Jul 18, 2023 at 23:24
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Commented Jul 18, 2023 at 23:24

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.