www.oradev.com   for Oracle developers
  Pl/sql articles   Oracle articles   Performance   scripts   Books   Documentation   Links   XML
  Articles
Oracle numeric functions
Number format
Sequence
dbms_lob
dbms_output
Oracle substr
Using a ref cursor
How to use the CASE statement
How to use the DECODE statement
How to use the NVL statement
Oracle training
Oracle certification
Create statistics
dbms_profiler explained
How to use hints
Autonomous transaction
Oracle date format
Oracle sysdate
Rename tables, columns
to_date function
Scheduling in 10g
How to use utl_http




  Autonomous transactions

Oracle autonomous transaction

An autonomous transaction is an independent transaction that is initiated by another transaction (the parent transaction). An autonomous transaction can modify data and commit or rollback independent of the state of the parent transaction.

The autonomous transaction must commit or roll back before the autonomous transaction is ended and the parent transaction continues.

An autonomous transactions is available from Oracle 8i.

An autonomous transaction is defined in the declaration of a pl/sql block. This can be an anonymous block, function, procedure, object method or trigger.
This is done by adding the statement 'PRAGMA AUTONOMOUS_TRANSACTION;' anywhere in the declaration block.

There isn't much involved in defining a PL/SQL block as an autonomous transaction. You simply include the following statement in your declaration section:
PRAGMA AUTONOMOUS_TRANSACTION;

Sample code:
PROCEDURE test_autonomous 
IS
  PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
   insert ....
   commit;
END test_autonomous;
Autonomous transactions can be used for logging in the database independent of the rollback/commit of the parent transaction.