LOCK

The LOCK utility allows a DBA to explicitly lock an area. This allows the DBA to place a lock on an area that will remain in effect across several commands. Access to an area can be prevented while a series of operations is performed on it.
idmscu19
The LOCK utility allows a DBA to explicitly lock an area. This allows the DBA to place a lock on an area that will remain in effect across several commands. Access to an area can be prevented while a series of operations is performed on it.
This article describes the following information:
2
2
Authorization
To lock an area, you need DBAWRITE access on the area.
Syntax
  ►►─── LOCK ┬─ AREA ── segment-name.area-name ┬──┬─────────────────────┬────►◄            └─ SEGment segment-name ──────────┘  └─ EXCLUSIVE UPDATE ◄─┘  
Parameters
  • AREA
    Directs the LOCK utility statement to lock a specified area.
  • segment-name
    Identifies the name of the segment associated with the area to be locked.
  • area-name
    Identifies the name of the area to be locked.
  • SEGMENT
    Specifies the segment whose areas will be locked.
  • segment-name
    Identifies the name of the segment to be locked.
  • EXCLUSIVE UPDATE
    Specifies the update mode. EXCLUSIVE UPDATE is the default mode and the only mode currently supported.
Usage
Local mode execution
If the LOCK AREA statement is issued through the batch command facility executing in local mode, a physical lock will be placed on the area. The lock remains in effect until an explicit UNLOCK is issued. If the area is already locked, the LOCK statement will fail with a DB002352 error message as illustrated in the sample output.
If the LOCK SEGMENT statement is issued in local mode, a physical lock will be placed on each area in the segment that is not already locked. A status of each area will be reported. Once all areas have been locked or checked, if any area in the segment was already locked, a DB002406 error message will be issued, as illustrated in the sample output.
Online execution
If the LOCK statement is issued through the online command facility (OCF) or through the batch command facility executing in a batch/CV mode, a logical lock will be placed on the area. This lock prevents all access to the area by other users until the session in which the LOCK statement is issued is committed. If executing online, a commit is automatically issued at end of task prior to the pseudo-converse unless autocommit is disabled through a SET OPTIONS statement.
The areas being locked must be varied in update mode to the central version. If another task is updating an area being locked, the LOCK command will wait until the logical area lock is available. If the wait would cause a deadlock, the LOCK command fails.
Committing prior work
Before executing this utility under a central version, you must commit any previous work done within the current session. For more information, see Central Version Considerations.
JCL Considerations
When you submit a LOCK statement through the batch command facility in local mode, the JCL to execute the facility must include statements to define the file containing the first page of the area to be processed. To run under central version, a SYSCTL statement is needed.
Examples
Lock by area
The following example directs the LOCK utility to lock the EMPDEMO.EMP-DEMO-REGION area.
lock area empdemo.emp-demo-region;
Lock by segment
The following example directs the LOCK utility to lock the EMPDEMO segment.
lock segment empdemo;
Sample Output
Lock by area
When LOCK processing is completed, the following listing is generated when processing is successful.
IDMSBCF nn.n                             CA IDMS Batch Command Facility             mm/dd/yy             PAGE 1    LOCK AREA EMPDEMO.EMP-DEMO-REGION;   Status = 0 SQLSTATE = 00000
When LOCK processing is completed, the following listing is generated when processing fails.
IDMSBCF nn.n                             CA IDMS Batch Command Facility             mm/dd/yy             PAGE 1    LOCK AREA USERDB.EMP_AREA;   Status = -4      SQLSTATE = 5000B        Messages follow: DB002352 C-4M353: Area USERDB.EMP_AREA required area lock mode not available
Lock by segment
When LOCK processing is completed, the following listing is generated.
IDMSBCF nn.n                             CA IDMS Batch Command Facility             mm/dd/yy             PAGE 1    LOCK SEGMENT EMPDEMO;    Area EMPDEMO.EMP-DEMO-REGION was not available    Area EMPDEMO.INS-DEMO-REGION Lock Mode Acquired    Area EMPDEMO.ORG-DEMO-REGION Lock Mode Acquired  Status = -4  SQLSTATE = 28000   Messages follow:  DB002406 C-4M363: Area lock mode unavailable for one or more areas