How to handle row error in direct path insert

时间:2019-03-19 14:40:32

标签: oracle performance error-handling

I have table A that I need to insert its data into table B.

The way I'm doing it is with direct path insert for performance issue:

INSERT /*+ append */ INTO
usr.B (c,d,e)
select c,d,e from usr.A;

Now I want to add an errors handling on row-level.

I mean that if there is an exception with some rows (because of constraints), the next rows will continue to insert into A, and the specific problematic rows will be saved in log table.

So I checked the option of DML error logging for that goal, but I found that it can't work with unique duplicates constraints in direct path statements, which is a very basic and important constraints in my tables.

I saw that solution that suggest to add fictive failure if there is duplicates, but it can't be good for me because of some reasons:

  1. I have a lot of tables (1000) which need to go over that process, so add that column for each table is impposible.

  2. The solution will help if there are duplicates in the source table already, but in my case can be one row in each table, so the duplicate check of the source data is not good enough.

Is there any idea how to do it right?

I know there is an option of SAVE EXCEPTIONS with FORALL but I realy prefer to use INSERT SELECT for all the rows with no loop.

Thanks.

0 个答案:

没有答案