Autonomous Transaction in oracle


Autonomous Transaction
Autonomous transactions refer to the ability of PL/SQL temporarily suspend the current transaction and begin another transaction.  The second transaction is known as an autonomous transaction. The autonomous transaction functions independently from the parent code.
An autonomous transaction has the following characteristics:









There are many times when you might want to use an autonomous transaction to commit or roll back some changes to a table independently of a primary transaction's final outcome.
We use a compiler directive in PL/SQL (called a pragma) to tell Oracle that our transaction is autonomous. An autonomous transaction executes within an autonomous scope. The PL/SQL compiler is instructed to mark a routine as autonomous (i.e. independent) by the AUTONMOUS_TRANSACTIONS pragma from the calling code.
As an example of autonomous transactions, let's assume that you need to log errors into a Oracle database log table. You need to roll back the core transaction because of the resulting error, but you don’t want the error log code to rollback.  Here is an example of a PL/SQL error log table: