Friday, December 31, 2010

What is autonomous transaction in Oracle?

  • 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. 
  • Autonomous transactions can be used for logging in the database independent of the rollback/commit of the parent transaction.
      CREATE OR REPLACE PROCEDURE test
      IS
             PRAGMA AUTONOMOUS_TRANSACTION;
      BEGIN
             insert ....
             commit;
      END;

What are ORACLE PRE-COMPILERS?

  • Using ORACLE PRE-COMPILERS, SQL statements and PL/SQL blocks can be contained inside 3GL programs written in C,C++,COBOL,PASCAL, FORTRAN,PL/1 AND ADA. 
  • The Precompilers are known as Pro*C,Pro*Cobol,This form of PL/SQL is known as embedded pl/sql,the language in which pl/sql is embedded is known as the host language. 
  • The pre-compiler translates the embedded SQL and pl/sql ststements into calls to the precompiler runtime library.The output must be compiled and linked with this library to create an executable.