OB_TRANSACTION_ID
Syntax
OB_TRANSACTION_ID()
Description
- If the current session is in an active transaction, this function returns the integer value of the transaction ID, which is greater than 0.
- If the current session is not in an active transaction, this function returns 0.
Examples
Query the transaction ID of the current session in an active transaction.
-
Start a transaction.
BEGIN; -
Query the transaction ID.
SELECT OB_TRANSACTION_ID();The return result is as follows:
+---------------------+
| OB_TRANSACTION_ID() |
+---------------------+
| 14565563 |
+---------------------+
1 row in set (0.001 sec) -
Commit the transaction.
COMMIT; -
Query the transaction ID of the current session not in an active transaction.
SELECT OB_TRANSACTION_ID();The return result is as follows:
+---------------------+
| OB_TRANSACTION_ID() |
+---------------------+
| 0 |
+---------------------+
1 row in set (0.001 sec)