Re: [sqlite] Inserting uniquely

2006-10-20 Thread Sergio 'OKreZ' Agosti


On 20/ott/06, at 17:06, Lloyd wrote:


Hi List,
  Is there is any easy way to insert a value to a table, if and  
only if

it is not existing ?

For example.

If I have these values 1,2,3,4,1,2,3,4
when I insert these to a table

it must be
1
2
3
4

[By using primary key or unique constraint, it will work. But I dont
want sqlite to throw error]

How can I get this done?


If you use INSERT OR IGNORE INTO table... you won't get any error  
thrown by sqlite


---
Sergio 'OKreZ' Agosti
---
icq: 112421063
msn: [EMAIL PROTECTED]
skype:   sergio.agosti
iChat:   sergio.agosti
jabber:  sergio.agosti
---


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



Re: [sqlite] Inserting uniquely

2006-10-20 Thread dcharno

Lloyd wrote:

Hi List,
  Is there is any easy way to insert a value to a table, if and only if
it is not existing ? 


http://sqlite.org/lang_conflict.html

ON CONFLICT clause
conflict-clause ::= ON CONFLICT conflict-algorithm
conflict-algorithm ::=  ROLLBACK | ABORT | FAIL | IGNORE | REPLACE

The ON CONFLICT clause is not a separate SQL command. It is a 
non-standard clause that can appear in many other SQL commands. It is 
given its own section in this document because it is not part of 
standard SQL and therefore might not be familiar.


The syntax for the ON CONFLICT clause is as shown above for the CREATE 
TABLE command. For the INSERT and UPDATE commands, the keywords "ON 
CONFLICT" are replaced by "OR", to make the syntax seem more natural. 
For example, instead of "INSERT ON CONFLICT IGNORE" we have "INSERT OR 
IGNORE". The keywords change but the meaning of the clause is the same 
either way.


The ON CONFLICT clause specifies an algorithm used to resolve constraint 
conflicts. There are five choices: ROLLBACK, ABORT, FAIL, IGNORE, and 
REPLACE. The default algorithm is ABORT. This is what they mean:




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



[sqlite] Inserting uniquely

2006-10-20 Thread Lloyd
Hi List,
  Is there is any easy way to insert a value to a table, if and only if
it is not existing ? 

For example.

If I have these values 1,2,3,4,1,2,3,4
when I insert these to a table

it must be 
1
2
3
4

[By using primary key or unique constraint, it will work. But I dont
want sqlite to throw error]

How can I get this done?

Thanks,
  Lloyd. 


__
Scanned and protected by Email scanner

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