On Wed, 26 Dec 2007 10:17:43 +0200, Ion Silvestru
<[EMAIL PROTECTED]> wrote:

>>>QUESTION: is there a better way to make this important decision? using
>>>Sqlite
>
>>INSERT OR REPLACE may work for you.
>
>There is a problem with "INSERT OR REPLACE" in that "REPLACE" is not
>truly <replace>, but is <delete + insert> (existing row is deleted and
>new row is added), or I am wrong?

It is a full replacement of the row, just as the word REPLACE
(Take the place or moveĀ into the position of) suggests. Perhaps
you are confused with UPDATE.
REPLACE has been introduced to increase compatibility with other
database engines, they all follow the same strategy.

>If I am correct, then a question to developers of SQLite:
>
>Is it difficult to change the behaviour of the "REPLACE" part of "INSERT OR 
>REPLACE"
>to be the correct behaviour, row content is updated, and not deleted then 
>inserted?

What would be the difference? 
I guess your new row doesn't provide some of the column values
of the existing row, and you want to keep some of those. In that
case, SELECT / UPDATE is the only option.

To change the behaviour of REPLACE into selective updating of
columns SQLite would have to know which columns it would have to
update and which not. It simply can't.

A nice solution is found in 
Date: Tue, 24 Apr 2007 14:36:48 -0400
Subject: [sqlite] Re: INSERT OR REPLACE without new rowid ,
Message-ID: <[EMAIL PROTECTED]> :

IT> You can do
IT>
IT> UPDATE ... WHERE keyfield='xxx';
IT>
IT> then use sqlite3_changes to see whether any update 
IT> has in fact taken place, and run INSERT if not.
IT>
IT> Igor Tandetnik 

>Thanks in advance and happy hollidays!

HTH
-- 
  (  Kees Nuyt
  )
c[_]

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

Reply via email to