Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.server -> Re: ignore error
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
![]() |
![]() |