Caché MultiValue Basic Reference
Obtains a logical process lock.
LOCK name [THEN statements] [ELSE statements]
||A number or a string, or an expression that evaluates to a number or a string specifying a lock name. Commonly, an integer from 0 through 64.
statement sets a named process lock, preventing other processes from obtaining a lock with the same name.
Process locks are not incremental: A process can set the same lock multiple times with LOCK
. A single UNLOCK
releases the lock
evaluates to an integer in the range 0 through 64. However, in Caché any number or string may be specified as a logical lock name. The lock name may not be empty, so LOCK ""
sets LOCK 0
You can specify optional THEN and ELSE clauses. If you obtain lock name
, the THEN clause is executed. If you already have lock name
, the THEN clause is also executed. If you could not obtain lock name
because it is held by another resource, the ELSE clause is executed. If you could not obtain lock name because it is held by another resource, the ELSE clause is executed.
locks, process locks set in a program are not released automatically when the program terminates. The lock belongs to the process, and persists for the life of the process, unless unlocked explicitly using the UNLOCK
The following example uses the LOCK
statement to obtain a logical lock named 17.
LOCK a THEN PRINT "Got the Lock"
ELSE PRINT "Couldn't get the lock"