Skip to main content
Version: V1.0.0

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.

  1. Start a transaction.

    BEGIN;
  2. 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)
  3. Commit the transaction.

    COMMIT;
  4. 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)