Tables 2, 3 and 4 show the default type of locking which is used when files are opened in a particular open mode. The default
locking can be modified if the AUTOLOCK Compiler directive was specified at the time the compilation group was submitted to
your COBOL system. The tables also indicate whether the default type of locking can be overridden for individual files. This
is done by inserting a suitable clause in the SELECT clause for the file. (See the topic The File Control Entry.)
X/Open restricts those X/Open conforming source programs that use locking to either single record locks with automatic locking,
or multiple record locks with manual locking.
Table 1. Default Locking For Record Sequential Files
OPEN Mode |
No Directive |
AUTOLOCK Compiler Directive |
Override in SELECT Statement |
INPUT |
No lock |
No lock |
Yes, but only to Exclusive |
I-O |
Exclusive |
Lock on single record |
Yes |
OUTPUT |
Exclusive |
Exclusive |
No |
EXTEND |
Exclusive |
No lock |
Yes, the file can be made shareable but no records are locked |
Table 2. Default Locking For Line Sequential Files
OPEN Mode |
No Directive |
AUTOLOCK Compiler Directive |
Override in SELECT Statement |
INPUT |
No lock |
No lock |
No |
I-O |
Exclusive |
No lock |
No |
OUTPUT |
Exclusive |
Exclusive |
No |
EXTEND |
Exclusive |
No lock |
No |
Table 3. Default Locking For Relative And Indexed Files
OPEN Mode |
No Directive |
AUTOLOCK Compiler Directive |
Override in SELECT Statement |
INPUT |
No lock |
No lock |
Yes, but only to Exclusive |
I-O |
Exclusive |
Automatic lock on single record |
Yes |
OUTPUT |
Exclusive |
Exclusive |
No |
EXTEND |
Exclusive |
Exclusive |
No |
Note:
- A file opened for OUTPUT causes the file to become exclusive, regardless of the specified lock mode.
- You can select the type of locking for individual files by accepting the default locking (see Tables 1, 2 and 3) or by including
a LOCK MODE clause in the file control entry (see the section The File Control Entry).