PreviousNextIndex

LOCKED function

Returns a TRUE value if a record is not available to a prior FIND . . . NO-WAIT statement because another user has locked a record.

Syntax

LOCKED record 

record
Example

The FIND statement in this procedure tries to retrieve a customer record according to a supplied customer number. Because of the NO-ERROR option, the FIND statement does not return an error if it cannot find the record. The NO-WAIT option causes FIND to return immediately if the record is in use by another user.

r-locked.p
REPEAT: 
  PROMPT-FOR Customer.CustNum. 
  FIND Customer USING Customer.CustNum NO-ERROR NO-WAIT. 
  IF NOT AVAILABLE Customer THEN DO: 
    IF LOCKED Customer THEN  
      MESSAGE "Customer record is locked". 
    ELSE  
      MESSAGE "Customer record was not found". 
    NEXT. 
  END. 
  DISPLAY Customer.CustNum Customer.Name Customer.City Customer.State. 
END. 

A record might not be available if it is locked (being used by another user) or does not exist. The LOCKED function returns a TRUE value if the record is locked. In this case, the r-locked.p procedure displays a message that the record is locked. If the record is not locked, the procedure displays a message that the record does not exist.

Note: The result of the LOCKED function depends on the lock mode specified. For example, if the FIND statement uses SHARE-LOCK and no user has an EXCLUSIVE-LOCK on the record, the LOCKED function returns FALSE. If the FIND statement uses SHARE-LOCK and another user has an EXCLUSIVE-LOCK on the record, the LOCKED function returns TRUE. The current copy of the record in the buffer to which the LOCKED function applies is not locked. Rather, LOCKED refers to an error condition that can occur if the record is locked. Consider using the NO-WAIT and NO-ERROR options on the FIND statement to return immediately and raise an error condition.
See also

AMBIGUOUS function, AVAILABLE function, FIND statement, NEW function (record buffers)


OpenEdge Release 10.2B
Copyright © 2009 Progress Software Corporation
PreviousNextIndex