What I meant was it'll ignore the error message, not ignore the constraint.

So where you're inserting 5 there it'd be wrong to think "well, there was no 
error, so 5 is in the database from either before or now"

Say you have imported resource X for November, then you get December's version 
and want to import only the new stuff. If you do "insert or ignore" then yes, 
you won't waste time replacing the old stuff, but you also won't get the error 
notification that there was an issue with the new copy of the resource.


-----Original Message-----
From: sqlite-users [mailto:sqlite-users-boun...@mailinglists.sqlite.org] On 
Behalf Of Simon Slavin
Sent: Thursday, December 21, 2017 1:15 PM
To: SQLite mailing list
Subject: Re: [sqlite] [EXTERNAL] How do I insert a record in an SQLite table 
only if the row does not already exist?



On 21 Dec 2017, at 3:46pm, David Raymond <david.raym...@tomtom.com> wrote:

> The only potential problem with "insert or ignore into" is that it will 
> ignore any constraint violation for that record insert

Not true.

sqlite> CREATE TABLE MyTable (a INTEGER, CONSTRAINT noless CHECK (a > 10));
sqlite> INSERT INTO MyTable VALUES (15);
sqlite> INSERT INTO MyTable VALUES (5);
Error: CHECK constraint failed: noless
sqlite> INSERT OR IGNORE INTO MyTable VALUES (6);
sqlite> SELECT * FROM MyTable;
15
sqlite> 

Simon.
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to