I want to insert a row if its key clm doesn't exist otherwise update
it. I can search for the row and then do either an insert or update
accordingly. However I was wondering whether the SQLite Conflict
Resolution: INSERT OR REPLACE would be more efficient (faster). The
problem is the REPLACE deletes the existing row and INSERT adds a new
one, loosing the ROWID value of the original row, which I need to
keep.

So my question is should I just forget this and do it the: select ->
if not found insert otherwise update way or is there a way to maintain
the original rowid using INSERT OR REPLACE?

If not what is the fastest way to check if a row exists, assuming the
search is on a single clm which is indexed. ex.
select myclm from mytable where myclm='abc';
select count(*) from mytable where myclm='abc';
add limit 1 to either of the above etc.

-- 
Best regards,
  Neville Franks, http://www.surfulater.com http://blog.surfulater.com
 

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to