Pretty straightforward, check if dbms_transaction.step_id is null!
SQL> select dbms_transaction.step_id from dual;
STEP_ID
---------------
SQL> insert into t values (1);
1 row created.
SQL> select dbms_transaction.step_id from dual;
STEP_ID
---------------
114352430549782
SQL> commit;
Commit complete.
SQL> select dbms_transaction.step_id from dual;
STEP_ID
---------------
SQL> insert into t values (2);
1 row created.
SQL> select dbms_transaction.step_id from dual;
STEP_ID
---------------
124248035235852
SQL> rollback;
Rollback complete.
SQL> select dbms_transaction.step_id from dual;
STEP_ID
---------------
You can do the same with DBMS_TRANSACTION.LOCAL_TRANSACTION_ID, which has the advantage of the documented behavior (see http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/d_transa.htm#i1000530) being, “It returns null if there is no current transaction.”
thanks for the update 🙂
I like this. Thanks.
Pingback: Transacciones Pendientes | Mi Blog sobre Oracle