Icon INTRANSACTION

Returns whether or not the current database, or a specific table in the current database, is currently in a transaction started by the START TRANSACTION statement.

Syntax
INTRANSACTION([<TableName>])

<TableName> =

Type of:

CHARACTER|CHAR
CHARACTER VARYING|VARCHAR
GUID
CHARACTER LARGE OBJECT|CLOB

Returns
BOOLEAN

Usage
The INTRANSACTION function returns the transaction status of the current database, or a table in the current database. This is useful in situations such as triggers where you may be updating tables that are already part of a transaction. Please see the CREATE TRIGGER statement for more information on creating triggers.

Examples
-- This trigger checks to see if the
-- current table is involved in a transaction
-- and starts a transaction, if necessary.

CREATE TRIGGER "CascadeChanges" AFTER UPDATE ON "customer"
BEGIN
   DECLARE LocalTrans BOOLEAN DEFAULT FALSE;

   IF (NEWROW.CustNo <> OLDROW.CustNo) THEN
      IF NOT INTRANSACTION('customer') THEN
         START TRANSACTION ON TABLES 'customer';
         SET LocalTrans=TRUE;
      END IF;
      BEGIN
         EXECUTE IMMEDIATE 'UPDATE Orders SET CustNo=?
                           WHERE CustNo=?' USING NEWROW.CustNo,OLDROW.CustNo;
         IF LocalTrans THEN
            COMMIT;
         END IF;
      EXCEPTION
         IF LocalTrans THEN
            ROLLBACK;
         END IF;
         RAISE;
      END;
   END IF;
END

SQL 2003 Standard Deviations
This function deviates from the SQL 2003 standard in the following ways:

DeviationDetails
ExtensionThis function is an ElevateDB extension.
Image