A resource, as used here, is not a real entity such as a file or a variable. It is a name, consisting of a primary name and optionally a minor name, to which NCL procedures refer.
The purpose of the lock mechanism is to provide assurance that a specific operation can be performed, at a particular point within an NCL procedure's logic, without interference or damage by other NCL processes that might be attempting to use the same data at the same time.
A common example is the case where a process needs to update a record on a UDB. The process reads the target record, changes it and writes it back to the file, but it also needs to guarantee that no other process updates the same record at the same time. To achieve this guarantee, the process first obtains exclusive access to a resource that symbolizes the record update process.
Once it has obtained this exclusive access, the procedure is free to perform as much work on the target record as it needs, knowing that no other procedure can access the same record in the meantime because no other procedure would be able to gain access to the resource lock.
It is important to remember that it is not the data itself that is protected by the lock mechanism, only the resource. If controlled access to an item of data is required then all procedures that change that data must gain access to the lock before updating the data.
| Copyright © 2011 CA. All rights reserved. | Tell Technical Publications how we can improve this information |