mercredi 7 octobre 2015

SQLite 'IF NOT EXISTS' syntax error

None of the other questions which address this error seems to work for me. My query is:

IF NOT EXISTS (SELECT 1 FROM Configuration WHERE key = 'CookieCount')
BEGIN
  INSERT INTO Configuration (key, value)
  VALUES ('CookieCount', '0')
END

and my error message is: "could not prepare statement (1 near "IF": syntax error)"

I have this working in Postgres: http://ift.tt/1VEiAgk But this does not work in SQLite and I need it to work with both.

Aucun commentaire:

Enregistrer un commentaire