When a READ is performed by an ILE COBOL program on a database file and the file is opened for I-O, a lock is placed on that record so that another program cannot update it. That is, the record can be read by another program if it opens a file for input, but not if it opens the file for I-O. Similarly, after a successful START operation for a file opened in I-O mode, a lock will be placed on the record at which the file is positioned.
For information about the duration of record lock with and without commitment control, refer to Figure 99.
To prevent the READ or START statements from locking records on files opened in I-O (update) mode, you can use the NO LOCK phrase. The READ WITH NO LOCK statement unlocks records locked by a previous READ statement or START statement. Also, the record read by the READ WITH NO LOCK statement is not locked. The START WITH NO LOCK statement unlocks records locked by a previous START statement or READ statement. For more information about this phrase, refer to the section on the READ and START statements in the WebSphere Development Studio: ILE COBOL Reference.
For a logical file based on one physical file, the lock is placed on the record in the physical file. If a logical file is based on more than one physical file, a lock is placed on one record in each physical file.
This lock applies not only to other programs, but also to the original program if it attempts to update the same underlying physical record through a second file.
For more information about releasing database records read for update, refer to the Database and File Systems category in the iSeries 400 Information Center at this Web site -http://publib.boulder.ibm.com/pubs/html/as400/infocenter.htm.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.