sql - Oracle not able to insert exception into table -
i have below procedure trying track exceptions i_log table.to test whether working or not have made ora-00933: sql command not ended error in query trying insert i_option table. when run procedure dbms output line printing error below not getting inserted i_log table:
others exception in ext_i_option - id:1000196-933----ora-00933: sql command not ended below procedure:
create or replace procedure "ext_i_option"(in_id in number default 0) err_code varchar(100); err_msg varchar(100); in_event_id number; in_db_link varchar2(50); in_env_id number; l_sql varchar2(5000); l_sql1 varchar2(5000); begin i_row in i_cur loop l_sql2 := insert i_option(id) select distinct(so.id) ) icard i; end loop; exception when others err_code := sqlcode; err_msg := substr(sqlerrm, 1, 200); insert i_log (i_id) values (i_id); raise; commit; end ext_i_option;
it seems have raise before commit; way, error raised before doing commit, don't find data in log table.
according suggestions, should define procedure handle log table:
create or replace procedure i_log (...) pragma autonomous_transaction; begin insert i_log(...); commit; end; / this procedure runs in separate transaction, commit of log data, no conflict data modify in main procedure. should modify error handling in way, avoiding commit statement, can dangerous, saving partial, unconsistent data:
dbms_output.put_line('others exception in ext_i_option - id:'||to_char(id) || err_code || '----' || err_msg ); ins_i_log(...); raise;
Comments
Post a Comment