This can be done by logging DML errors if you are on 10gR2 or later.
Example:
SQL> create table my_table (my_column) 2 as 3 select level from dual connect by level <= 9 4 / Tabel is aangemaakt. SQL> create function do_something 2 ( p_my_column in my_table.my_column%type 3 ) return my_table.my_column%type 4 is 5 begin 6 return 10 + p_my_column; 7 end; 8 / Functie is aangemaakt. SQL> alter table my_table add check (my_column not in (12,14)) 2 / Tabel is gewijzigd. SQL> exec dbms_errlog.create_error_log('my_table') PL/SQL-procedure is geslaagd.
This creates an error log table named err $ _my_table. This table is populated by adding a suggestion about log errors to the update statement:
SQL> begin 2 update my_table 3 set my_column = do_something(my_column) 4 where my_column is not null 5 log errors reject limit unlimited 6 ; 7 end; 8 / PL/SQL-procedure is geslaagd. SQL> select * from err$_my_table 2 / ORA_ERR_NUMBER$ -------------------------------------- ORA_ERR_MESG$ -------------------------------------------------------------------- ORA_ERR_ROWID$ -------------------------------------------------------------------- OR -- ORA_ERR_TAG$ -------------------------------------------------------------------- MY_COLUMN -------------------------------------------------------------------- 2290 ORA-02290: check constraint (RWK.SYS_C00110133) violated AAGY/aAAQAABevcAAB U 12 2290 ORA-02290: check constraint (RWK.SYS_C00110133) violated AAGY/aAAQAABevcAAD U 14 2 rijen zijn geselecteerd.
Up to 10gR2 you can use the SAVE EXCEPTIONS clause: http://rwijk.blogspot.com/2007/11/save-exceptions.html
Rob van Wijk
source share