END [TRANSACTION | WORK]
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.
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.
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"