On Fri, 03 Jul 2009 14:38:43 -0700, James Gregurich
<bayouben...@mac.com> wrote:

>
>nuts. that makes INSERT OR REPLACE worthless if you have tables  
>dependent on one another.
>
>
>Is there any way to manually get a list of records for which there  
>would be a conflict if a given record was inserted?

BEGIN;
INSERT the row, and observe any UNIQUE constraint failures.

If there isn't one, the INSERT succeeded and you're done.

If it failed, proceed to :
DELETE FROM yourtable 
        WHERE PK  = yournewPKvalue
      OR CK1 = yournewCK1value
      OR CK2 = yournewCK2value
      .... ;
and repeat the INSERT.

COMMIT;

Legend:
PK  = primary key column
CKn = candidate key column #n
-- 
  (  Kees Nuyt
  )
c[_]
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to