URGENT - LOCKED question

nate100

Member
Hello,
Is it that that you can check to see if a record is LOCKED only if you do an exclusive-lock?

I have the record open in the application so I know it is already in use.

If I do:

FIND FIRST so_mstr WHERE so_domain = 'us1' and so_nbr = 'S1027688'
EXCLUSIVE-LOCK NO-WAIT NO-ERROR.
IF LOCKED so_mstr then display
'LOCKED'.

It display LOCKED.

If I do:

FIND FIRST so_mstr WHERE so_domain = 'us1' and so_nbr = 'S1027688'
NO-LOCK NO-WAIT NO-ERROR.
IF LOCKED so_mstr then display
'LOCKED'.

It does not show LOCKED.

Also if I do:

FIND FIRST so_mstr WHERE so_domain = 'us1' and so_nbr = 'S1027688'
EXCLUSIVE-LOCK NO-WAIT NO-ERROR.
IF AVAILABLE so_mstr AND LOCKED so_mstr then display
'LOCKED'.

If I add the AVAILABLE it does not display LOCKED.

Any ideas?

Thanks
 
nate100,
i could be wrong, and i'm sure someone will point it out if i am but i think it is only reading the lock if you lock it. - when you say no-lock you are not locking the record. you may have the record open in an application but that does not mean that the application has an exclusive lock on the record, could be a share lock.
regards,
longhair
 
nate100,
i could be wrong, and i'm sure someone will point it out if i am but i think it is only reading the lock if you lock it. - when you say no-lock you are not locking the record. you may have the record open in an application but that does not mean that the application has an exclusive lock on the record, could be a share lock.
regards,
longhair

When you are reading the record with an exclusive-lock and another process already has an exclusive-lock on this record then Progress will not read the record in your record buffer. Because of this the available check will return false (not available). It is not available because it cannot be read because it is locked. The only way to read a locked record is by using find no-lock.

You should always first check if your record is available. If it is then there is no problem ;-) If it is not then you should check if it is not available because it is already locked by another. If it is also not locked then the record does not exists ;-)

The same applies to the ambigious function.
 
When you do a find exclusive-lock with the no-wait option then the error condition is raised if the record is exclusive-locked by another process.

If the find-statement uses no lock then the record can be retrieved and no error condition is raised and the locked function returns false.

If the find statement uses share-lock and another proces has the record also with a share lock. Locked also returns false.

Only when the find statement is shared or exclusive lock and the record to be retrieved is exlcusive-locked by another user the locked function returns true.

If you do a find share/exclusive lock with the no-error option then there are two reasons the error condition is raised:
  1. The record doesn't exists
  2. The record is exclusive locked by another process
So to distinguish between these 2 options you can use

Code:
find record exclusive-lock no-wait no-error.
if not available [I]record[/I] and
locked [I]record[/I] then display 'record is locked'.
else if not available [I]record[/I] then display 'record doesn't exist'.

HTH,

Casper.

(BTW it can't be that urgent it's in the online help :awink:)
 
Back
Top