RECORDLOCKL, RECORDLOCKU

RECORDLOCKL, RECORDLOCKU

Top  Previous  Next

 

The RECORDLOCKL statement sets a read lock on a record. The RECORDLOCKU statement is similar but sets an update lock.

 

 

Format

 

RECORDLOCKL file.var, record.id {ON ERROR statement(s)}

{LOCKED statement(s)}

 

where

 

file.varis the file variable associated with the file.

 

record.idevaluates to the key of the record to be locked.

 

statement(s)are statements to be executed depending on the outcome of the operation.

 

 

The RECORDLOCKL statement sets a read lock on record record.id of the file open as file.var. The RECORDLOCKU statement sets an update lock.

 

The LOCKED clause is executed if the file or record is locked by another process in a manner than prevents further locking. The STATUS() function will return the user id of a process holding a lock that is blocking this action or zero if the lock table is full. If the LOCKED clause is omitted and the file or record is locked, the program will wait for the lock to be released.

 

A process may lock records within files for which it also holds the file lock. These statements may also be used to convert an existing read lock to an update lock or vice versa.

 

 

Example

 

RECORDLOCKL STOCK, "ORDER.LIST" LOCKED

  DISPLAY "Waiting. Order list locked by user " : STATUS()

  RECORDLOCKL STOCK, "ORDER.LIST"

END

 

This program fragment attempts to lock record ORDER.LIST of the file open as STOCK. If it is locked, a message is displayed and a second RECORDLOCKL statement is executed without a LOCKED clause to wait for the lock.