I have a problem to get the right information about an error when trying to insert a row in a table.
Let’s have an example.
So we create a test table that has four (04) columns.
drop table test_tab;
create table test_tab
(
var1 number(2) ,
var2 number(2) ,
var3 number(1) ,
var4 number(2)
);
Then, we create a log table to log errors when inserted rows doesn’t match the table requirements (columns size).
drop table test_tab_err_log;
begin
dbms_errlog.create_error_log(dml_table_name => 'test_tab'
, err_log_table_name => 'test_tab_err_log');
end;
/
Then, we try to insert a row to that table and violate the third column requirements.
SQL> insert into test_tab
2 select 0,0,25,0
3 from dual
4 log errors
5 into test_tab_err_log ('INSERT')
6 reject limit unlimited
7 ;
0 rows created.
The problem is, when we fetch about the rows that caused an error, the returned message doesn’t tell us which column provokes the error.
SQL> column ora_err_mesg$ format a80
SQL> select ora_err_number$, ora_err_mesg$ from test_tab_err_log;
ORA_ERR_NUMBER$ ORA_ERR_MESG$
--------------- --------------------------------------------------------------------------------
1438 ORA-01438: value larger than specified precision allowed for this column
real: 15
SQL>
So, is there a way or a workaround to know that the var3 column has been violated.
Thanks in advance,