30 pts.
 When will AS/400 record lock?
Hi Guru's , I am new to RPG . I would like to know when record will be locked ? Example-1 : PGMA, using a PF1(Physical file) in input mode , PGMB using a logical file based on PF1, in input mode. In this case record will be locked or not (using read or chain or setll operation codes) ? If I will use pf1 in PGMA as inupt mode and in PGMB as update mode , does record will be locked or not ? I have seen when both the files in both the programs using file type in update modere record has been locked .

Software/Hardware used:
ASKED: September 25, 2010  8:58 AM
UPDATED: September 28, 2010  7:11 AM
  Help
 Approved Answer - Chosen by TomLiotta

Assuming that you are using native I/O .. F specs and reads and chains .. not SQL
and further assuming that you are not using commitment control

A record is locked when it is acquired, as in a chain or read, by a program that has opened the file for Update (not input). It remains locked until
- the program ends or the file is closed
- the record is updated or deleted
- another record is acquired by this program through the same access path.
- the record is unlocked

Access to a record that is locked will not be possible by another program or job that is attempting to acquire that record for update. A program/job can acquire a locked record when that program/jobs access path is for input.

Phil

ANSWERED:  Sep 28, 2010  1:34 AM (GMT)  by TomLiotta

 
Other Answers:
Last Wiki Answer Submitted:  June 27, 2012  2:06 am  by    0 pts.
Latest Answer Wiki Contributors: 
To see other answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

Only a couple things to add that I can think of.

SQL will also lock rows that are being updated. And a record is locked when it is acquired for update.

That last bit is useful because a program can open a file in update mode and read records without locking them. This is done in RPG IV by specifying CHAIN or any READ op-code with the (N) extender. A lock won’t be set until the record is eventually input without the (N) extender. That lets you delay the lock until your program has finished all processing of the data. That is most useful in interactive programming when a user might have a record for a long time.

There doesn’t seem to be much else to add.

Tom

 107,695 pts.