Microsoft KB Archive/40365

Record and File Locking Defined for COBOL Version 3.0

PSS ID Number: Q40365 Article last modified on 04-20-1993

3.00 3.00a | 3.00 3.00a MS-DOS | OS/2

Summary: In a network environment, it is necessary to protect specific records or an entire file from other programs on the network. This is accomplished by record locking or file locking.

More Information: Record locking refers to denying access of a specific record or set of records to other programs that are running on a network. File locking refers to denying access of a file to other programs on the network. The type of locking to be used is specified in the SELECT statement. File locking is specified by using the EXCLUSIVE clause. Record locking is specified by using the MANUAL or AUTOMATIC clause. File locking syntax in Microsoft COBOL Version 3.0 or 3.0a is as follows: SELECT file-name ASSIGN TO DISK LOCK MODE IS EXCLUSIVE. When AUTOMATIC record locking is specified, the COBOL system issues the locks. A record is locked when it is in the FD and the lock is retained until another record is read into or written into the FD. Record-locking syntax in Microsoft COBOL Version 3.0 or 3.0a is as follows: SELECT file-name ASSIGN TO DISK LOCK MODE IS AUTOMATIC. MANUAL record locking allows the programmer to issue the locks with the READ statement. MANUAL record locking also allows you to lock more than one record by specifying with KEPT LOCK on the READ. Only files open for INPUT allow record locking. SELECT file-name ASSIGN TO DISK LOCK MODE IS MANUAL. READ file-name WITH LOCK. READ file-name WITH KEPT LOCK. More information on networking can be found in this KnowledgeBase, in Chapter 12 of the “Microsoft COBOL Version 3.0: Operating Guide”, and in Chapter 5 of the “Microsoft COBOL Version 3.0: Language Reference Manual.”

Additional reference words: 3.00 3.00a Copyright Microsoft Corporation 1993.