DB2 Program Execution Process


A DB2 program can be executed in multiple ways, depending on the environment and type of SQL being used. We can run DB2 programs using batch processing, online (CICS) execution, or interactive tools like SPUFI.

To execute COBOL + DB2 program, the program should successfully BIND first. We can run a DB2 program in the following ways:

  1. Batch Mode (JCL + COBOL/DB2 Programs)
  2. Online Mode (CICS + DB2 Programs)

Runtime Supervisor -

The runtime supervisor is responsible for validating the timestamps of COBOL and DB2 object codes. It checks the timestamp tokens of the object code of COBOL (T1) & timestamp from DBRM (T2) updated in DB2 plan or package.

  • If T1=T2, the program is ready for execution.
  • If T1 not = T2, the program ABENDs with SQLCODE -818 (timestamp mismatch error).
Running DB2 program

Batch Mode -


In batch mode, a COBOL + DB2 program runs as part of a batch job through JCL. This method is used for scheduled or large-scale processing.

After successful BIND, the program will need a RUN JCL to execute the program. IKJEFT01 utility is used to execute the program through JCL.

RUN JCL for COBOL + DB2 program -

//JOB-CARD
//STEP01 EXEC PGM=IKJEFT01
//SYSIN DD *
	RUN PROG (program-name) -
	PLAN (plan-name)        -
	LIB (prog-load-library)
/*
  • PROG (program-name) - Specifies the name of the compiled program.
  • PLAN (plan-name) - Specifies the DB2 plan it is bound.
  • LIB (prog-load-library) - Specifies the program load library where it resides.

Example -

Scenario - Execute the program PROG1.

//...
//STEP1 EXEC PGM=IKJEFT01
//SYSIN DD *
	RUN PROG (PROG1) -
	PLAN (PLAN1)     -
	LIB ('MATEPK.COBDB2.LOADLIB')
/*
...

Online Mode -


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 or 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.