Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRIS, see the InterSystems IRIS Adoption Guide and the InterSystems IRIS In-Place Conversion Guide, both available on the WRC Distributions page (login required).

Previous sectionNext section

END TRANSACTION

Specifies where to continue execution after a transaction.

Synopsis

END [TRANSACTION | WORK]

Description

The END TRANSACTION statement specifies the end of a transaction. This is where to continue program execution following a COMMIT statement or a ROLLBACK statement.

If an END TRANSACTION is encountered before either a COMMIT or a ROLLBACK, the current transaction is rolled back.

The TRANSACTION or WORK keywords are optional and provides no functionality. They are provided solely for compatibility with other MultiValue vendor products.

Note:

Caché MVBasic supports two sets of transaction statements:

  • UniVerse-style BEGIN TRANSACTION, COMMIT, ROLLBACK, and END TRANSACTION.

  • UniData-style TRANSACTION START, TRANSACTION COMMIT, and TRANSACTION ABORT.

These two sets of transaction statements should not be combined.

Example

The following example performs database operations within a transaction. It sets a variable x, which determines whether the transaction should be committed or rolled back.

PRINT "Before the transaction"
BEGIN TRANSACTION
 .
 .
 .
IF x=0 
  THEN COMMIT
  END
  ELSE ROLLBACK
  PRINT "Transaction rolled back"
  END
PRINT "This should not print"
END TRANSACTION
PRINT "After the transaction"
Copy code to clipboard

See Also