11.07.2015 Views

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

Caché ObjectScript Reference - InterSystems Documentation

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Caché</strong> <strong>ObjectScript</strong> Commands• Sets the lock table count for those lock names to 1. By default it sets the Exclusive locktable count; if lock type is #"S", it instead sets the Shared lock table count to 1 for thatlock name.The following example sets a simple lock on lock name ^a.LOCK ^aThis command requests an exclusive lock: no other process can simultaneously hold a lockon this resource. If another process already holds a lock on this resource (exclusive or shared),this example must wait for that lock to be released. It can wait indefinitely, hanging the process.To avoid this, specifying a timeout value is recommended.If a simple lock is issued during a transaction, the release of previously held resources isdeferred until the completion of the transaction. A simple lock acquired during a transactioncannot be released during that transaction. (Incremental locks can be released during atransaction using the Immediate Unlock lock type.) The TCOMMIT command completesthe transaction and releases all locks held during the transaction.The following example sets simple locks on lock names ^b, ^c, and ^d as a group.LOCK (^b,^c,^d)Note that like all simple locks, this LOCK command first releases all locks previously heldby the process. Thus the lock ^a held by the previous command would be released by issuingthis command.The grouping parentheses are required when issuing a simple lock with multiple lock names.These parentheses cause LOCK to lock all of the specified resources. If a timeout is specified,either all of the specified resources are locked or the LOCK command times out and noneof them are locked.If the parentheses were omitted, the command LOCK ^b,^c,^d would be parsed as threesimple lock commands, with the result of first releasing previously held locks and locking^b, then immediately releasing ^b in order perform a simple lock on ^c, then immediatelyreleasing ^c in order perform a simple lock on ^d. As a result, only ^d would be locked.Incremental LockingIncremental locking permits you to set multiple locks on the same resource. Your processcan then increment and decrement this lock count. As of <strong>Caché</strong> 4.1, the lock table maintainsindependent lock counts for exclusive locks and shared locks.Issuing an incremental lock does the following:84 <strong>Caché</strong> <strong>ObjectScript</strong> <strong>Reference</strong>

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!