Implementation of a table level locks in a COBOL-DB2 program during SQL execution


The locks in DB2 are acquired on table and tablespaces to avoid the issues arising due to LOST UPDATE, DIRTY READ and PHANTOM.

We need to define the lock parameter during the BIND package/plan step using the ACQUIRE option.

A COBOL-DB2 program PROGA is using SQL statements to access table TA. If we need to place a lock on the table only when that particular SQL statement is executed within the program, then we need to define the BIND JCL step as below−

//BIND EXEC PGM=IKJEFT01
//STEPLIB DD DSN=DIS.TEST.LOADLIB,DISP=SHR
//SYSOUT DD SYSOUT=*
//SYSTSIN DD *
DSN SYSTEM(TB3)
BIND PLAN(PLANA) -
PKLIST(PACKA) -
ACQUIRE(USE) -
/*

The option ACQUIRE has to be used with the USE parameter in the BIND PLAN step. This will direct the DB2 to place the lock on the DB2 table when the SQL statement using that table is executed in the program.

Updated on: 11-Sep-2020

547 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements