Cool website, James. I bookmarked it for future reference.

Thanks for your help, it will come in handy...

--
Bill Drago
Senior Engineer
L3 Communications / Narda Microwave East
435 Moreland Road
Hauppauge, NY 11788
631-272-5947 / william.dr...@l-3com.com



> -----Original Message-----
> From: sqlite-users-boun...@sqlite.org [mailto:sqlite-users-
> boun...@sqlite.org] On Behalf Of James K. Lowden
> Sent: Tuesday, November 04, 2014 6:23 PM
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] How to check if a record exists
>
> On Tue, 4 Nov 2014 21:47:20 +0000
> "Drago, William @ CSG - NARDAEAST" <william.dr...@l-3com.com> wrote:
>
> > I've been pulling my hair out trying to figure how to use EXISTS.
>
> I have several examples at
> http://www.schemamania.org/sql/#missing.table.
>
> > Is there a better/recommended way in SQLite to check if a record
> > exists?
> >
> > static bool IDisDuplicate(string dbFileName, int id)
>
> Yes.  Assert, don't check!
>
> Your function is checking for duplicates.  I could be wrong of course,
> but I suspect that you're checking for duplicates to do something about
> it in the database.  If so, between the time you check and the time you
> "do something" that duplicate could have gone away and another arisen.
> Cache coherency folks call that a write-after-read error.
>
> The way to avoid that is to put everything on the broad shoulders of
> SQLite, viz,
>
>       insert/update/delete T as t
>       -- ... --
>       where exists (
>               select 1 from T
>               where something = t.something
>               group by something
>               having count(*) > 1
>       );
>
> HTH.  Exists is confusing at first, and consequently under-appreciated.
>
> (BTW, I dis duplicates, too.  Despise them, in fact.)
>
> --jkl
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
CONFIDENTIALITY, EXPORT CONTROL AND DISCLAIMER NOTE:This e-mail and any 
attachments are solely for the use of the addressee and may contain information 
that is privileged or confidential. Any disclosure, use or distribution of the 
information contained herein is prohibited. In the event this e-mail contains 
technical data within the definition of the International Traffic in Arms 
Regulations or Export Administration Regulations, it is subject to the export 
control laws of the U.S.Government. The recipient should check this e-mail and 
any attachments for the presence of viruses as L-3 does not accept any 
liability associated with the transmission of this e-mail. If you have received 
this communication in error, please notify the sender by reply e-mail and 
immediately delete this message and any attachments.
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to