Declaration
OB_TRANSACTION_ID()
Description
- If the current session is in an active transaction, the transaction ID as an integer greater than 0 is returned.
- If the current session is not in an active transaction, return 0.
Examples
Query the transaction IDs of active transactions in the current session.
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 IDs that are not currently in active transactions.
obclient [test]> SELECT OB_TRANSACTION_ID();The return result is as follows:
+---------------------+ | OB_TRANSACTION_ID() | +---------------------+ | 0 | +---------------------+ 1 row in set