Showing posts with label PLSQL Autonomous Transaction. Show all posts
Showing posts with label PLSQL Autonomous Transaction. Show all posts

Tuesday, October 2, 2018

PLSQL Autonomous Transaction

Autonomous Transaction

Autonomous Transactions:-Autonomous transaction is a independent Transaction that is called by another transaction.
                         Autonomous Transactions is a way by which we can call function or procedure as a complete transaction without affecting main transaction (Calling Environment).

Note:-When an autonomous transaction is called, the main transaction (calling transaction) is being temporarily suspended. The autonomous transaction must commit or roll back before it returns 
      to calling transaction.

Declaration :- PRAGMA AUTONOMOUS_TRANSACTION;

Example:-
Declare
PRAGMA AUTONOMOUS_TRANSACTION;
begin
update emp set sal=sal+2000 where deptno=10;
commit;
end;
/
update emp set sal=sal+5000 where deptno=20;

rollback;

Note:-When rollback executed here then only last update statement will rollbacked so here executed procedure is working as a autonomous transaction.

PLSQL utl_file Package

Utl_File Utl_File  : This is the Oracle supplied package which is used for extracting data from Oracle queries into csv file or in other...