Skip to content
Prev 1147 / 1559 Next

SQLite - inserting a row conditional on its existence

On Tue, Mar 20, 2012 at 9:00 AM, Lescai, Francesco <f.lescai at ucl.ac.uk>wrote:

            
This is a SQLite syntax error.  An insert query cannot include a where
clause, I don't think.  You might try (untested):

INSERT OR IGNORE INTO "variation" VALUES(NULL, :name, :reference_allele,
:validation_status).

You'll need to have a unique constraint in place for this to work as
expected.  See here:

http://www.sqlite.org/lang_insert.html

and here:

http://www.sqlite.org/lang_conflict.html


Sean