Skip to main content

Database Integrity

ObjectScript provides several commands to help ensure database integrity: Lock, TStart, and TCommit. You need to know about these in preparation for adding deletion and editing capabilities to ObjectScript.Lookup2. 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 method uses Lock, but another doesn't, nothing prevents the second method from updating the record while the first method 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 indexes, for example) remain in sync.

FeedbackOpens in a new tab