Syntax
OB_TRANSACTION_ID()
Purpose
- If the current session is in an active transaction, the procedure returns the integer value of the transaction ID, which is greater than 0.
- If the current session is not in an active transaction, the procedure returns 0.
Examples
Query the transaction ID of the current session in an active transaction.
Start a transaction.
obclient [test]> BEGIN;Query the current transaction ID.
obclient [test]> SELECT OB_TRANSACTION_ID();The return result is as follows:
+---------------------+ | OB_TRANSACTION_ID() | +---------------------+ | 14565563 | +---------------------+ 1 row in setCommit the transaction.
obclient [test]> COMMIT;Query the transaction ID of the current session not in an active transaction.
obclient [test]> SELECT OB_TRANSACTION_ID();The return result is as follows:
+---------------------+ | OB_TRANSACTION_ID() | +---------------------+ | 0 | +---------------------+ 1 row in set
