I have shown my proc at high level below. While executing this proc for some reason i get Primary key violation on table my_tab_mf during insert, so the procedure as expected jumps to EXCEPTION block. When it comes to proc My_PKG_MF.LOG_ERROR in the exception block i get the error: ORA-06519: active autonomous transaction detected and rolled back. The proc My_PKG_MF.LOG_ERROR is an autonomous proc which has COMMIT inside it. Can somebody help me understand why i get this error though i have a COMMIT in the autonomous proc? The proc My_PKG_MF.LOG_ERROR calls another proc: MASTER.my_pkg_master.log_db_err in another schema called MASTER.
Im in 10gR2 version.
procedure proc_mf
as
v_proc_name varchar2(50) := 'proc_mf';
Err_Code varchar2(50);
Err_Desc varchar2(500)
begin
delete from table my_tab_mf;
insert into my_tab_mf (col1,col2)
select col1, col2 from a,b;
EXCEPTION
WHEN OTHERS
THEN
ROLLBACK;
Err_Code := SQLCODE;
Err_Desc := SUBSTR(SQLERRM, 1, 256);
My_PKG_MF.LOG_ERROR(v_proc_name
,To_Char(Err_Code)
,Err_Desc
);
end proc_mf;
-- Contents of AUTONOMOUS proc My_PKG_MF.LOG_ERROR
procedure LOG_ERROR(proc_name in varchar2 ,err_code in varchar2 ,err_desc in varchar2)
is
PRAGMA AUTONOMOUS_TRANSACTION;
begin
--logging the error into the log table
insert into my_log_mf
values(proc_name ,err_code,err_desc);
--calling another Error logging proc which is in another schema called Master
MASTER.my_pkg_master.log_db_err(proc_name ,err_code,err_desc);
COMMIT;
end LOG_ERROR;
Edited by: michaelrozar17 on Mar 20, 2013 2:31 AM