Hello,

I am experimenting with the SQLite Upsert syntax:
https://www.sqlite.org/lang_UPSERT.html

Based on the grammar, I would expect a query like this to work:

create table person (
  name text primary key
  count int default 0
);

insert into person ('name') values ('hello')
on conflict do update set count = excluded.count + 1;

However, I get a syntax error:

> while attempting to perform prepare "insert into person (name) values
('a') on conflict do update set count = excluded.count + 1;": near
"update": syntax error

It would appear that the index list is required by the implementation, as
this works:

insert into person ('name') values ('hello')
on conflict (name) do update set count = excluded.count + 1;

The index list is not required with "nothing":

insert into person ('name') values ('hello')
on conflict do nothing;

Am I misreading the grammar chart? If this is a difference between the
grammar and the implementation, which one should be updated?

Thanks,
Matt Parsons
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to