Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: ignore error

Re: ignore error

From: <markp7832_at_my-deja.com>
Date: Mon, 24 Jan 2000 14:06:08 GMT
Message-ID: <86hm8d$dle$1@nnrp1.deja.com>


In article <86h4r1$ln$1_at_justice.csc.cuhk.edu.hk>,   "Jeff" <kit_at_cintec.cuhk.edu.hk> wrote:
> Hi,
>
> How do you ignore the unique constraint error when inserting tables
from a
> selected results, such that all records are inserted with duplicates
records
> left behind?
>
> Thanks.
>
> Jeff
>

With pure sql you can not ignore errors but you can use pl/sql with an exception block like:

begin
open c_select;
loop
  fetch c_select into v_variables;
  exit when c_select%notfound;
  begin
  insert into target_table
    values (v_variables...)
  exception
    dup_val_on_index then null;
  end; -- of error traping block
end loop ;
end ;

You need to define your variables or use a cursor for loop but this in the best way I know.

--
Mark D. Powell -- The only advice that counts is the advice that  you follow so follow your own advice --

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Mon Jan 24 2000 - 08:06:08 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US