oracle - Log all errors for a value into error log if a single row fails -


I am trying to maintain data integrity and logging errors in the error table. I have 3 tables with unique tables and 1 error table:

  create table tbl_one (pass_no number, obligation tbl_one_u01 unique (pass_no)); Enter tbl_one values ​​(10); Insert tbl_one values ​​(20); Create table tbl_two (cus_no number, cus_name varchar2 (50), pass_no number, constraint tbl_two_u01 unique (cus_no)); Insert Tbl_two values ​​(101, 'Nmx', 10); Insert Tbl_two values ​​(102, 'name', 10); Insert Tbl_two values ​​(103, 'Names', 20); Creating table tbl_target (cus_no number, pass_no number, obstruction tbl_target_u01 unique (cus_no), obstruction tbl_target_u02 unique (pass_no)); Exec dbms_errlog.create_error_log ('tbl_target', 'tbl_target_err');   

I'm trying to log all ORA-00001 errors from error table tbl_target_err :

  in tbl_target Tbl_one to b.pass_no = a.pass_no log errors in tbl_target_err deny range 10 select tbl_one from a.pass_no, b.cus_no; End;   

The result is:

  choose * from tbl_target; ------------------- CUS_NO PASS_NO 101 10 103 20   

and error table:

  CUS_NO PASS_NO 102 10   

I need all the violation errors to go into the error table. If value of pass_no 10 violates, then all values ​​must be 10 in the error table; No, I do not want to use the existing statement for one goal and one error table because I can not log all violation values.

How can I go about doing this?

You can not use the error logging mechanism because it is not designed to support it has gone. It tries to duplicate errors in the table - the first value that it attempts to include for pass_no 10, is valid for itself - so the difference between the data it already exists To start with, there are many values ​​to come from and coming from. So you have to do your own role.

To capture duplicates, create an own set of options, and to determine which values ​​are added to each table, enter a insert Use: Create table tbl_target_dup (cus_no number, pass_no number); Insert all when cus_count = 1 and pass_count = 1 then select tbl_target_dup values ​​(cus_no, pass_no) in tbl_target values ​​(cus_no, pass_no) in another a.pass_no, b.cus_no, count (*) over (a.pass_no) ) As the passmount, count (*) over (split by b.cus_no) from cus_count to tbl_one bbl. Tb_b at b.pass_no = a.pass_no;

This allows you to have more columns than those affected by PK / UK, and if you want, just enter them in the actual table, or subscribe in the 'Error' table. . With just two columns in each table: Choose

  with * tbl_target; CUS_NO PASS_NO ---------- ---------- 103 20 * Choose from tbl_target_dup; CUS_NO PASS_NO ---------- ---------- 101 10 102 10   

.

You can do this with the same inspection on the basis of two code inserts, with the investigation of a sub-class, both of which are calculated 1, the other checks That's not the least one, but it can perform better.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -