Prevent record lock scenario with AS/400 ?

130 pts.
Tags:
AS/400 DB2
AS/400 Locking
AS/400 Records
Record lock
Suppose 2 users are accesssing the same record in a file.User 1 tried to update the record and while doing so he did not log-off from his update screen,while the user tries to do inquiry on that same record. As a result there will be a record lock situation.How to prevent this scenario ? i need possible solutions.

Software/Hardware used:
as400

Answer Wiki

Thanks. We'll let you know when a new response is added.

If you design the processes so that they access the record for input with no locks then the problem doesn’t exist. That would mean using READ(N) or CHAIN(N) ( N for no lock).
Displaying the screen, waiting for a change without the record locked.
When the program receives the changed screen to proceess would:
1. Access record and lock it
2. Check record to insure that it hasn’t been updated by another user
3. Update it.
The lock last’s very short time, less than the file time out limit.
If, at step 2, the file has changed, don’t update it — show the new data and a messaage that it was changed and allow the user to change it again.
Phil

With or without the above change, inquiry mode which should access the record with an F-Spec of input rather than update shouldn’t encounter a locked record.
Phil

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
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
  • TomLiotta
    You can't "prevent" record locks nor do you want to. You can minimize the impact by using a technique like Phil's. The lock is going happen as soon as a record is read in update mode. You can read it in inquiry mode and hold it as long as you want. When it's time to apply any updates to the record, you can read it again in update mode, test it to see if it's different from what you read the first time, apply the changes to the record image and issue the update. (If it changed, you need to release the current update lock and go back to reading the record in inquiry mode again to start over. The user should be notified of the conflict, as Phil noted above.) Or you might use some kind of timer. The program is most likely using a display file to allow changes to be typed. You might associate a data queue and a timeout with the display file to prevent anyone from holding a locked record for more than a few minutes. If the user goes to lunch, the program might automatically enforce releasing the lock. How exactly do you want the application to work? Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    Ohhh .. are you working in COBOL .. SQL .. what commit level? Phil
    49,850 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

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

REGISTER or login:

Forgot Password?
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

Thanks! We'll email you when relevant content is added and updated.

Following