Mega Code Archive

 
Categories / Oracle PLSQL Tutorial / PL SQL Statements
 

Mark an anonymous block pragma autonomous_transaction

SQL> SQL> create or replace package global_variables   2  as   3      x number;   4  end;   5  / Package created. SQL> SQL> begin   2      global_variables.x := 5;   3  end;   4  / PL/SQL procedure successfully completed. SQL> SQL> declare   2      pragma autonomous_transaction;   3  begin   4      global_variables.x := 10;   5      commit;   6  end;   7  / PL/SQL procedure successfully completed. SQL> SQL> set serveroutput on SQL> exec dbms_output.put_line( global_variables.x ); 10 PL/SQL procedure successfully completed. SQL>