Microsoft KB Archive/33224

Network File- and Record-Lock Support for the Four OPEN Modes

PSS ID Number: Q33224 Article last modified on 04-21-1993

3.00 | 3.00 MS-DOS | OS/2

Summary: The following OPEN modes are available in Microsoft COBOL Version 3.0 on a (supported) network. (For all OPEN modes, when you do not use a LOCK MODE IS phrase in the SELECT clause, the locking mode defaults to file-level locking): 1. OPEN OUTPUT a. You cannot share files OPENed for OUTPUT. b. Files OPENed for OUTPUT are always locked at the file level. 2. OPEN INPUT a. Files can be shared. b. File-level locks are available. c. No record-level locking is available. 3. OPEN I-O a. File-level locks and record-level locks are both available. b. You can have AUTOMATIC record-level locking or MANUAL record-level locking. c. You can specify one lock to be allowed at a time in the file using the WITH LOCK ON RECORD phrase in the SELECT clause, as follows: SELECT file-name ASSIGN TO DISK LOCK MODE IS AUTOMATIC WITH LOCK ON RECORD. The above example uses AUTOMATIC locking, with only one record allowed to be locked at a time in the file. In AUTOMATIC lock mode, the program automatically locks a record when a READ is executed. d. You can also specify many locks to be allowed at a time (in files with relative or indexed organization only), using the WITH LOCK ON MULTIPLE RECORDS phrase in the SELECT clause, as follows: SELECT file-name ASSIGN TO DISK LOCK MODE IS MANUAL WITH LOCK ON MULTIPLE RECORDS. The above example uses MANUAL locking, where you use READ WITH KEPT LOCK syntax in the PROCEDURE DIVISION to acquire locks on multiple records at a time. You may also use AUTOMATIC locking, where each READ automatically locks a record. 4. OPEN EXTEND a. File-level and record-level locks are both available.

Additional reference words: 3.00 Copyright Microsoft Corporation 1993.