HP 3000 Manuals

Multiple Record Locking [ Micro Focus COBOL for UNIX COBOL User Guide ] MPE/iX 5.0 Documentation


Micro Focus COBOL for UNIX COBOL User Guide

Multiple Record Locking 

A program that specifies multiple record locking for a file can
simultaneously hold several record locks.  This prevents other programs
from accessing these locked records but does not deny them access to any
records that are not locked.  Multiple record locks for a program can be
acquired in either of two ways:  manually or automatically.

Manual Multiple Record Locking 

You can specify automatic single record locking for a file in your
program by using the LOCK MODE IS MANUAL WITH LOCK ON MULTIPLE RECORDS
clause in the SELECT statement.

Your program can acquire a lock by accessing a record with a READ WITH
KEPT LOCK statement.  If you used the WRITELOCK 
directive at the time you compiled your program, it acquires a manual
multiple record lock whenever it accesses the file with a WRITE or
REWRITE statement.  These locks are released when your program does one
of the following:

   *   closes the file

   *   executes a COMMIT statement

   *   executes a ROLLBACK statement

   *   executes an UNLOCK statement for the file.

Automatic Multiple Record Locking 

You can specify automatic multiple record locking by using the LOCK MODE
IS AUTOMATIC WITH LOCK ON MULTIPLE RECORDS clause in the SELECT
statement.

Your program acquires an automatic multiple record lock whenever it reads
a record in the file.  If you specified the WRITELOCK 
directive at the time you compiled your program, it also acquires a lock
whenever the program accesses the file with a WRITE or REWRITE statement.

The locks are released when your program does one of the following:

   *   closes the file

   *   executes a COMMIT statement

   *   executes a ROLLBACK statement

   *   executes an UNLOCK statement for the file.



MPE/iX 5.0 Documentation