Updating a physical file

380 pts.
Tags:
Physical File
RPGLE
RPGLE files
Suppose I have a RPGLE Program P1 And P2 and a physical file PF1 . P1 using PF1 in update mode and p2 also using Pf1 in update mode. When P1 calls P2, it throws an error saying file locked. What can be done. I need to update pf1 in both the progs.
ASKED: April 2, 2013  2:59 PM
UPDATED: April 2, 2013  3:45 PM

Answer Wiki

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

In your F specs you are defineing the file as an Update file. The default then when youi read a record is to lock the record. You need to either execute an instruction to unlock the record or when you get the record with a READ or CHAIN you need to read it without the lock. READ(N) or CHAIN(N),

Now with that said, when you actually want to update the record, you need to retrieve it with out the (N) else it cannot be updated.

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
    The read-without-lock followed by a later read-with-lock for update is one good way to go. Best would possibly be not to update the file in P1 nor in P2. Instead, only have a single program update the file, program P3.   Have both P1 and P2 call P3. Pass the update record image to P3. Make P3 be a program that receives a record image and updates PF1 and does nothing else. All update logic and error testing would be in a single program. That program would be the only one that would apply locks.   This program would be called by all other programs that ever needed to update PF1.   Unless the logic is isolated and encapsulated, there will always be possible lock conflicts.   With read-without-lock and later read-with-lock for update, you need to compare the original record image against the locked record image to ensure that no updates have been done between the two reads. If an update is detected, the user needs to be notified to decide how to handle it. The user might choose to go back to the beginning of the transaction or might make other choices.   Tom
    125,585 pointsBadges:
    report
  • jainamit
    Thnx a lot Tom :-)
    380 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