Skip to main content

This is documentation for Caché & Ensemble.

For information on converting to InterSystems IRISOpens in a new window, see the InterSystems IRIS Migration Guide and Migrating to InterSystems IRIS, both available on the WRC Distributions pageOpens in a new window (login required).

Database Integrity

ObjectScript provides several commands to help ensure database integrity: Lock, TStart, and TCommit. We'll cover these in preparation for adding editing capabilities to the lookup routine. These three commands usually appear near each other. In general, you should use them in this way:

  1. Select a record for editing.

  2. Lock the record.

  3. Get the updated data for the record.

  4. TStart a transaction.

  5. Store the new data.

  6. TCommit the transaction.

  7. UnLock the record.

You use the Lock command to prevent multiple processes from updating the same record at the same time. But it only works by convention: all the code throughout an application that updates a given global must try to Lock the record that is to be updated, and unLock it when finished. If one routine uses Lock, but another doesn't, nothing prevents the second routine from updating the record while the first routine has it locked.

You use the TStart and TCommit commands to protect database transactions. A transaction is simply a series of Set and/or Kill commands on the database. You need to ensure that an entire transaction completes, or that none of it completes. This guarantees that all the globals in a transaction (for both data and indices, for example) remain in sync.

FeedbackOpens in a new window