Begins a transaction.
Caché MVBasic supports two sets of transaction statements:
These two sets of transaction statements should not be combined.
There is a fundamental difference in the way Caché transactions operate in comparison to most other transaction systems in the MV world. In Caché, items written to a file are immediately available both to the writing process and any other process accessing the file. If the transaction is aborted either programmatically or because of some failure, then the item will be rolled back to the state prior to the start of the transaction.
Most other transaction systems in the MV world will make an item written to a file available to the process that wrote the item (in other words, if it reads the item back from the file after the write, it will be given the version that it wrote to the file), but any other process READing the item will see the version of the item as it was before a write. This is generally referred to as the isolation level. This difference may have implications for systems that wish to scan files without taking locks.
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"
PRINT "Transaction rolled back"
PRINT "This should not print"
PRINT "After the transaction"
© 1997-2019 InterSystems Corporation, Cambridge, MA