Re: [sqlite] Duplicate Row check

2007-07-19 Thread Joe Wilson
> When i do a insert is there a way to know row already exists!!

Not without querying.

But you could do something like this:

  CREATE TABLE t1(a PRIMARY KEY, b, c);

  insert into t1 
select 7, 'foo', 'bar' where not exists (
  select null from t1 where a=7);

which is similar to:

  INSERT OR IGNORE INTO t1 values(7, 'one', 'two');

except that the first insert form does not require any indexes
to work, and you have more flexibility with the where clause.

If you wish to insert a row if it does not exist, or update the
row if it does exist you can use REPLACE INTO:

  REPLACE INTO t1 values(7, 'what', 'ever');



   

Get the Yahoo! toolbar and be alerted to new email wherever you're surfing.
http://new.toolbar.yahoo.com/toolbar/features/mail/index.php

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Duplicate Row check

2007-07-19 Thread Ken
You can put a Primary Key (unique index) on the table.
 Then when inserting a duplicate, an error will be generated.
 Then test for the error.  
 
 Or if you want the new row to overwrite the original use insert or replace 
 
 If you goal is to keep the existing use insert or ignore.
 
 see:
 
 http://www.sqlite.org/lang_conflict.html
 
 

RaghavendraK 70574 <[EMAIL PROTECTED]> wrote: Q was incomplete.
When i do a insert is there a way to know row already exists!!

regrads
ragha

**
 This email and its attachments contain confidential information from HUAWEI, 
which is intended only for the person or entity whose address is listed above. 
Any use of the information contained herein in any way (including, but not 
limited to, total or partial disclosure, reproduction, or dissemination) by 
persons other than the intended recipient(s) is prohibited. If you receive this 
e-mail in error, please notify the sender by phone or email immediately and 
delete it!
 
*

- Original Message -
From: RaghavendraK 70574 
Date: Thursday, July 19, 2007 5:17 pm
Subject: [sqlite] Duplicate Row check

> Hi,
> 
> How can check if a row exists in the db or not without querying for 
> it?
> regards
> ragha
> 
> 
> **
> This email and its attachments contain confidential information 
> from HUAWEI, which is intended only for the person or entity whose 
> address is listed above. Any use of the information contained 
> herein in any way (including, but not limited to, total or partial 
> disclosure, reproduction, or dissemination) by persons other than 
> the intended recipient(s) is prohibited. If you receive this e-mail 
> in error, please notify the sender by phone or email immediately 
> and delete it!
> 
> *
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> 
> -
> 
> 

-
To unsubscribe, send email to [EMAIL PROTECTED]
-




RE: [sqlite] Duplicate Row check

2007-07-19 Thread Michael Flum
If you can, define one of the data entries in your table (Schema
defination) as "unique" when you create the table. The engine will then
set an error condition (call the callback function) and this should
prevent you from entering duplicate data and hence duplicate rows.

Michael

-Original Message-
From: RaghavendraK 70574 [mailto:[EMAIL PROTECTED] 
Sent: Thursday, July 19, 2007 8:00 AM
To: sqlite-users@sqlite.org
Subject: Re: [sqlite] Duplicate Row check

Q was incomplete.
When i do a insert is there a way to know row already exists!!

regrads
ragha


**
 This email and its attachments contain confidential information from
HUAWEI, which is intended only for the person or entity whose address is
listed above. Any use of the information contained herein in any way
(including, but not limited to, total or partial disclosure,
reproduction, or dissemination) by persons other than the intended
recipient(s) is prohibited. If you receive this e-mail in error, please
notify the sender by phone or email immediately and delete it!
 

*

- Original Message -
From: RaghavendraK 70574 <[EMAIL PROTECTED]>
Date: Thursday, July 19, 2007 5:17 pm
Subject: [sqlite] Duplicate Row check

> Hi,
> 
> How can check if a row exists in the db or not without querying for 
> it?
> regards
> ragha
> 
> 
>

**
> This email and its attachments contain confidential information 
> from HUAWEI, which is intended only for the person or entity whose 
> address is listed above. Any use of the information contained 
> herein in any way (including, but not limited to, total or partial 
> disclosure, reproduction, or dissemination) by persons other than 
> the intended recipient(s) is prohibited. If you receive this e-mail 
> in error, please notify the sender by phone or email immediately 
> and delete it!
> 
>

*
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> 
> -
> 
> 


-
To unsubscribe, send email to [EMAIL PROTECTED]

-


-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Duplicate Row check

2007-07-19 Thread P Kishor

On 7/19/07, RaghavendraK 70574 <[EMAIL PROTECTED]> wrote:

Q was incomplete.
When i do a insert is there a way to know row already exists!!



what is the definition of "row already exists"? If you are concerned
about a particular column, make that into a PK. If you are concerned
about all the columns, make all the columns into a composite PK. Your
program will croak accordingly. Else, just first do a SELECT before
doing an INSERT. Use CONFLICT clause to handle conflicts.


--
Puneet Kishor http://punkish.eidesis.org/
Nelson Inst. for Env. Studies, UW-Madison http://www.nelson.wisc.edu/
Open Source Geospatial Foundation http://www.osgeo.org/education/
S Policy Fellow, National Academy of Sciences http://www.nas.edu/
-
collaborate, communicate, compete
=

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Duplicate Row check

2007-07-19 Thread Joe Wilson
> How can check if a row exists in the db or not without querying for it?

Isn't the very act of asking whether it exists a query unto itself?



   

Looking for a deal? Find great prices on flights and hotels with Yahoo! 
FareChase.
http://farechase.yahoo.com/

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



Re: [sqlite] Duplicate Row check

2007-07-19 Thread RaghavendraK 70574
Q was incomplete.
When i do a insert is there a way to know row already exists!!

regrads
ragha

**
 This email and its attachments contain confidential information from HUAWEI, 
which is intended only for the person or entity whose address is listed above. 
Any use of the information contained herein in any way (including, but not 
limited to, total or partial disclosure, reproduction, or dissemination) by 
persons other than the intended recipient(s) is prohibited. If you receive this 
e-mail in error, please notify the sender by phone or email immediately and 
delete it!
 
*

- Original Message -
From: RaghavendraK 70574 <[EMAIL PROTECTED]>
Date: Thursday, July 19, 2007 5:17 pm
Subject: [sqlite] Duplicate Row check

> Hi,
> 
> How can check if a row exists in the db or not without querying for 
> it?
> regards
> ragha
> 
> 
> **
> This email and its attachments contain confidential information 
> from HUAWEI, which is intended only for the person or entity whose 
> address is listed above. Any use of the information contained 
> herein in any way (including, but not limited to, total or partial 
> disclosure, reproduction, or dissemination) by persons other than 
> the intended recipient(s) is prohibited. If you receive this e-mail 
> in error, please notify the sender by phone or email immediately 
> and delete it!
> 
> *
> 
> -
> To unsubscribe, send email to [EMAIL PROTECTED]
> 
> -
> 
> 

-
To unsubscribe, send email to [EMAIL PROTECTED]
-



[sqlite] Duplicate Row check

2007-07-19 Thread RaghavendraK 70574
Hi,

How can check if a row exists in the db or not without querying for it?

regards
ragha


**
 This email and its attachments contain confidential information from HUAWEI, 
which is intended only for the person or entity whose address is listed above. 
Any use of the information contained herein in any way (including, but not 
limited to, total or partial disclosure, reproduction, or dissemination) by 
persons other than the intended recipient(s) is prohibited. If you receive this 
e-mail in error, please notify the sender by phone or email immediately and 
delete it!
 
*

-
To unsubscribe, send email to [EMAIL PROTECTED]
-