Use EXCLUSIVE-LOCKs
- Last Updated: April 22, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
Your first test involves using EXCLUSIVE-LOCKs. To test locking conflicts when using an
EXCUSIVE-LOCK:
- From your first session, create a new procedure window by selecting the menu item.
- Enter this code to retrieve the first Customer record with an exclusive lock:
FIND Customer 3000 EXCLUSIVE-LOCK. DISPLAY "User 1 has locked:" NAME. WAIT-FOR CLOSE OF THIS-PROCEDURE. - In the Procedure Editor in your second session, enter the same procedure,
but with a message that says User 2 instead of User 1:
FIND Customer 3000 EXCLUSIVE-LOCK. DISPLAY "User 2 has locked:" NAME. WAIT-FOR CLOSE OF THIS-PROCEDURE. - Run the first procedure. The window for the first session comes up:
- Run the procedure in the second session. Because it is trying to get an
exclusive lock on a record already locked by the other process, you get a message telling
you that the record is in use and that you must either wait or cancel out of the
FINDstatement:
If you close the first window, the second process can now read and lock the Customer record:
This example illustrates the most basic rule of record locking.
Only one user can have an EXCLUSIVE-LOCK on a record
at a time. Any other user trying to lock the same record must either
wait for it or cancel the request.