Re: How to avoid appending matching records ?

From: Robert Poortinga <poorting_at_silver.ucs.indiana.edu>
Date: Mon, 20 Apr 1992 12:20:48 -0500
Message-ID: <1992Apr20.122055.22413_at_bronze.ucs.indiana.edu>


In article <1992Apr16.011759.6548_at_cbnews.cb.att.com> lvc_at_cbnews.cb.att.com (Larry Cipriani) writes:
>I have two tables A and B which share a common schema.
>In that schema I have 60 fields, f1, f2, ... f60.
>
>Basically, I want to append B - A to A, but I want the
>difference to operate only on two fields f1, and f2. From
>what I can tell, 'MINUS' operates on entire records.

How about:

  insert into A
    select * from B

     where (B.f1, B.f2)
     not in (select A2.f1, A2.f2 from A A2)
  ;

>Or ...
>
>If I have a unique index i_a on fields f1 and f2 of A and
>then insert all of B into A the whole insert will fail if
>there is one record from B that matches an indexed record
>in A. Is there a way to make sqlplus keep going and ignore
>the duplicate indexes errors ? That is, inserts on other
>records should succeed but the duplicates should be thrown
>away ?

Try writing a PL/SQL procedure if you want. It may be faster than the above example.

Bob Poortinga
(poorting_at_silver.ucs.indiana.edu) Received on Mon Apr 20 1992 - 19:20:48 CEST

Original text of this message