From a COBOL program I an reading a random access file and occasionally try to read a locked record. What can I do to speed up the read so I can just present a popup screen that tells the user he is trying to access a locked record. Right now it takes 60 secs to time out from the read attempt before I can present this screen. BY then many users simply kill their session out of frustration. Any help would be appreciated.

(1) If doing a Cobol READ, you can avoid the question of locks by using READ WITH NO LOCK.

(2) If doing an SQL SELECT, you can avoid the question of locks by using WITH NC as the last clause.

(3) In various OSes, you can set your general commitment level to read without locking, or set your timeout to some arbitrarily low value, such as 0. Setting the timeout to 0, in most systems, means that you will not wait for a record at all. Watch out. In some, it means to wait forever. You can always set your timeout to a very low nonzero number, through.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy

Processing your response...

Discuss This Question: 5 &nbspReplies

There was an error processing your information. Please try again later.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy

If you need to keep the 60-second wait time for record locking in place and you also need to read the file for update in your current application, you can implement "soft lock" processing as follows:
1) Add the field "Locked By User Id" to the file
2) Every time the program reads the file for update, add the user id to this field
3) Every time the user has finished updating, remove the user-id from this field
4) Add a statement before the read for update step (which is holding up the users for 60 seconds) that reads without update so that the wait time for record lock is not in effect.
5) Check for a soft lock - check if the "Locked by User Id" field is not blanks. If not blanks, display the User Id in a meesage on the screen letting the current user know who is locking it. This will display instantly rather than the file wait time.
6) The only problem with this approach is that the soft lock remains on the record if a job is cancelled before the soft lock is removed. You will need to provide the users an override when the soft lock exists which means that they can try to update anyway (usually after they check with the user in the message to see if they are really locking the record). You can do this by making the message display in a window which gives them the option to read for update regardless of the warning that the record is locked. If they decide to override the soft lock warning, the worst that will happen is that they will have to wait 60 seconds if the record is truly locked just like they did before.

If you cannot change the physical file wait time, you can also override the record wait time with an OVRDBF before opening the file with your program.
We normally change it to *NONE in this situation so you get an immediate signal back to the program.

A nice aspect of the override is that it applies only in that job. It doesn't change the file, and that means it doesn't mess with timings in other jobs. An override can tune the behavior for each individual job.
Tom

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy

Processing your reply...

Ask a Question

Free Guide: Managing storage for virtual environments

Complete a brief survey to get a complimentary 70-page whitepaper featuring the best methods and solutions for your virtual environment, as well as hypervisor-specific management advice from TechTarget experts. Don’t miss out on this exclusive content!

Share this item with your network:

To follow this tag...

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States.
Privacy