Microsoft KB Archive/33223

AUTOMATIC File Locking Compared to MANUAL Locking

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

3.00 | 3.00 MS-DOS | OS/2

Summary: This article compares the two record-level locking modes that are available in COBOL Version 3.0: AUTOMATIC and MANUAL locking. The lock mode is specified in the SELECT clause of the FILE-CONTROL paragraph in the ENVIRONMENT DIVISION.

More Information: The following is a description of AUTOMATIC and MANUAL locking: 1. SELECT … LOCK MODE IS AUTOMATIC a. When lock mode is AUTOMATIC, a compiled program will automatically lock records for the user. b. For locks on a single record, the READ statement gets a lock, and the lock is released on the next file access, except for a START. c. For multiple record locks, the READ statement gets a lock, and the locks are released when UNLOCK, CLOSE, or COMMIT statements are executed. 2. SELECT … LOCK MODE IS MANUAL a. When MANUAL lock mode is specified, you must use the WITH LOCK or WITH KEPT LOCK syntax in the READ statement (in the PROCEDURE DIVISION) to explicitly lock records when needed. No locks will be acquired by the file if you use the following statement when locking is MANUAL: READ b. Single record locks: The following statement locks a record that is unlocked on the next file access (except for a START): READ WITH LOCK c. Multiple record locks: The following statement locks a record; the records kept locked are unlocked with the UNLOCK, CLOSE, or COMMIT statements: READ WITH KEPT LOCK

Additional reference words: 3.00 Copyright Microsoft Corporation 1993.