Autonomous transaction
597601Nov 23 2007 — edited Nov 23 2007Hi Friends,
When a function or a procedure has a Autonomous_Transaction pragma included in it, That particular function cannot perform any DML [Insert, Update, Delete] on a table. I have just started learning ORACLE, correct me if I am wrong.
But, I have noticed a different behavior between ORACLE SQL Developer 1.2.1 and SQLPLUS [ORACLE 10g Release2] on the below Autonomous_transaction
Function abc(txt in varchar(20))
return rec_count number
as
pragma Autonomous_Transaction;
begin
Proc_Ins(txt);
select count(*) into rec_count from sam_tab;
delete from sam_tab;
commit;
return;
end;
procedure Pro_ins(text varchar(20))
is
begin
insert into sam_tab values(text);
end;
When i execute the function abc i get a result but when i execute the same abc function through SQLPLUS i get the following error:
ERROR:
ORA-14551: cannot perform a DML operation inside a query
ORA-06512: at "abc", line 8
ORA-06519: active autonomous transaction detected and rolled back
Please correct me if i am wrong