* Mag. Wilhelm Braun <[EMAIL PROTECTED]> [2007-12-25 15:10]:
> QUESTION: is there a better way to make this important
> decision? using Sqlite

1. If you are changing the entire row on every update, you can
   simply use `INSERT OR REPLACE` (assuming there is a UNIQUE
   column) to always do this in a single query.

   See <http://sqlite.org/lang_conflict.html>.

2. If you only want to update some of the columns, particularly
   if you are likely to update rows several times, you can use
   `UPDATE` to try and update, and if this did not affect any
   rows you do an `INSERT`.

In #1, you always get the job done with a single query. In #2,
you are usually done after the first but sometimes need a second.
Both are more efficient than your current approach, which always
runs two queries.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

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

Reply via email to