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