What can be done if we want to update a record locked by other program or application in RPGLE

Viewed 56

Suppose I want to update a record , but that record is being locked by some other application or program , what can be done to make sure that I can update that record in the next iteration?

3 Answers

If this program was running in batch and it was critical that the record in question gets updated, you could use the (E) extender on your Chain and monitor for the %Error. Something like this:

// This record MUST be updated
Dou %Error = *Off;
  Chain(E) (FileKey) CriticalFile
Enddo;

// At this point, we've gotten past the file lock
If %Found(CriticalFile);
  Update CriticalFileRec;
Endif;

The Do-Until will continuously loop until a successful chain is achieved.

Nothing. A lock is issued by another application and that application needs to free it.

The rule to follow is that record locks should never be retained during key think time. That is the job should have no record locks when it runs the exfmt statement to write the display format and wait for the user to press the enter key. This includes any updates which have not yet been committed when running under commitment control. Always run SQL COMMIT before a blocking DSPF read.

Related