INSERT OR IGNORE? 

-----Original Message-----
From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-boun...@sqlite.org] 
On Behalf Of Simon Slavin
Sent: Tuesday, September 24, 2013 2:16 PM
To: General Discussion of SQLite Database
Subject: Re: [sqlite] Bug : Tcl interface + "INSERT OR REPLACE" statement


On 24 Sep 2013, at 7:09pm, Marc L. Allen <mlal...@outsitenetworks.com> wrote:

> Also, there are times when you do a bulk insert, so you have to structure the 
> query to not fail on records that are already present.

Yeah.  Actually I got what I posted wrong.  I should have written

Which is why you do an INSERT OR FAIL, then do the UPDATE.
Or do an UPDATE first and iff that fails, do an INSERT.

The first version (INSERT OR FAIL, then UPDATE) won't lead to any SQLite errors 
if one of the rows already exists. So you can do a whole lot of both lines in 
one transaction and the transaction will still succeed.

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


This email and any attachments are only for use by the intended recipient(s) 
and may contain legally privileged, confidential, proprietary or otherwise 
private information. Any unauthorized use, reproduction, dissemination, 
distribution or other disclosure of the contents of this e-mail or its 
attachments is strictly prohibited. If you have received this email in error, 
please notify the sender immediately and delete the original.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to