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]
-----------------------------------------------------------------------------