DB2 - Program Execution Process




DB2 Program Execution Process

Unlike a normal COBOL program COBOL DB2 program has some special requirements to be considered while coding and execution. For ex: In the coding it is required to include the SQLCA and the program needs to be executed via Terminal monitor Program etc.

To execute COBOL + DB2 program, the program should BIND successfully first. the execution process is depending on the executing environment.

Batch environment

After successful BIND, the program will need a JCL to RUN. IKJEFT01 utility is used to execute the program through JCL. The below one is the RUN JCL for COBOL+DB2 program −

//JOB CARD
//S-1 EXEC PGM=IKJEFT01
//SYSIN DD *
	RUN PROG (P1) PLAN (Pl1)
	DSN SYSTEM (DSP/DST)
	LIB (Z.Z.A)
/*
//

In the above,


P1			- 	Program name which needs to execute.
Pl1			-	Plan name to which the program BIND.
DSP/DST			-	DB2 system name
Z.Z.A			-	Library name

Online Environment

After successful BIND, program new copy to be issued in CICS environment. Before running the module, the RCT entry for the program should be defined in the region. Otherwise, query execution will fail with -922 error.

Once the new copy successfully issued, LINKing/CALLing the program from other program is sufficient to run the COBOL + DB2 program. If the COBOL + DB2 module has a transaction associated with it, triggering transaction also initiates the execution.

What is DB2 Program Execution Process ?

We have already discussed this in our previous topic. I will brief those over here, For a normal COBOL program only compiling the code will be enough to create a load module. But in case of COBOL-DB2 program, the compiler does not understand the SQL statements. As a result compiler will throw inconsistent results. So Pre compilation process got introduced.

So in COBOL DB2 compilation 4 parts will be there. Pre-compilation, COBOL module compiles, Bind Link EDIT

COBOL compiler did not understand about SQL statement so, it undergoes to precompile. In precompile. Expands all include copybooks which are written in program. Extracts all SQL statements into DBRM and SQL statement are convert into call statements. Generates time-stamp for modified source codes and DBRM .there are checked at run time. Check syndicated error of SQL statements and validates the fields based on the table declaration from dclgen copybook.

Notes − precompilation process can be executed even if DB2 is down.

Package

A package is a single bond DBRM which contains optimized access path (OAP) to DB2. Package contains one or more DBRMS. It’s an intermediate component between Plan and DBRM. The main advantage of the package is, rebind is not required when any change in sub program. Compilation of subprogram is only sufficient.

Plan

Plan contains also optimized access path, which is executable component. By using the Plan we execute the package. Plan have below things, One or more DBRM. One or more package. Combination of both DBRM & package. Group of packages is called collection.

//STEP01 EXEC PGM= IKJEFT01
//SYSTSIN DD *
DSN
BIND PLAN(plan‐name)
VALIDATE(validate‐opt) > BIND, RUN
MEMBER(DBRM‐member‐name)
ISOLATION(isolation level) > CS,RR,UR
RELEASE(release‐options) > COMMIT, DEALLOCATE
LIB(‘DBRM LIBRARY’) ISOLATION
/*

VALIDATE

Validate used to control the handling of objects. The validate options are RUN, BIND. Validate will not through any error messages during the bind and it will through warning messages at the time of Running.