RECORDLOCKED()

RECORDLOCKED()

Top  Previous  Next

 

The RECORDLOCKED() function indicates whether a given record is locked.

 

 

Format

 

RECORDLOCKED(file.var, record.id)

 

where

 

file.varis the file variable associated with the file.

 

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

 

 

The RECORDLOCKED() function returns a value indicating the state of any locks on record record.id of the file open as file.var. The tokens shown in the table below are defined in the KEYS.H record of the SYSCOM file.

 

 

Value

Token

Lock state

-3

LOCK$OTHER.FILELOCK

Another user holds a file lock

-2

LOCK$OTHER.READU

Another user holds an update lock

-1

LOCK$OTHER.READL

Another user holds a read lock

0

LOCK$NO.LOCK

The record is not locked

1

LOCK$MY.READL

This user holds a read lock

2

LOCK$MY.READU

This user holds an update lock

3

LOCK$MY.FILELOCK

This user holds a file lock

 

A record may be multiply locked in which case the RECORDLOCKED() function reports only one of the current locks. File locks take precedence over read or update locks. If no file lock is set, read or update locks held by the process in which the RECORDLOCKED() function is performed take precedence over locks held by other processes.

 

Executing the STATUS() function after a RECORDLOCKED() function indicates that a lock is active will return the user number of the user holding the lock.

 

 

Example

 

IF RECORDLOCKED(STOCK, "ORDER.LIST") THEN

  DISPLAY "Record is locked by user " : STATUS()

END

 

This program fragment checks if record ORDER.LIST is locked and, if so, reports the user number of the process that holds the lock.