Progress
Programming
Handbook
Bypassing Progress Lock Protections
In some cases you might want to read a record even though another user holds an EXCLUSIVE–LOCK on that record. For example:
For cases such as these, Progress allows you bypass the normal locking mechanism and access a record with NO–LOCK. For example,
p-lock6.p
produces a simple customer report:
Because the FOR EACH statement in this example uses the NO–LOCK option, the procedure accesses every customer record without error even if another user holds an EXCLUSIVE–LOCK on one or more records.
For a browse widget, NO–LOCK is the default mode. If you want to update a record, then you must find that record again to apply a lock. For example,
p-lock7.p
browses records with NO–LOCK but allows you to select a record to update:
When you run this procedure and choose the upd–cust button, the trigger finds the current record again and applies an EXCLUSIVE–LOCK to it. You can then update the record.
NOTE: If you read a record with NO–LOCK before a transaction starts and then read the same record with EXCLUSIVE–LOCK within the transaction, the EXCLUSIVE–LOCK is automatically downgraded to a SHARE–LOCK when the transaction ends. Progress does not automatically return you to NO–LOCK status. If you do not want to hold a lock beyond the end of the transaction, you must execute a RELEASE statement on the record within the transaction.In
p-lock7.p
, because a RELEASE statement is executed in the transaction, the record lock is released after the transaction completes.Because NO–LOCK bypasses the normal Progress lock protection, there are risks in using NO–LOCK. For example, in
p-lock7.p
, the customer names you see in the browse widget might not be up-to-date. Another user might have updated one or more records since you retrieved them. You receive no warning that your data is no longer current. However, when you execute the FIND statement in the upd–cust trigger, you retrieve the up-to-date record.
Copyright © 2004 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |