BIND DB2 Program (for Experienced)


DB2 program can bound to either package or plan. IKJEFT01 utility is used to bound the DBRM to the package or plan.

Note! In this topic, we have taken COBOL as an application language. So, we have explained about COBOL + DB2 program bind process below.
  • If the module is a batch module (COBOL + DB2), bound the module to package is sufficient to execute.
  • Suppose the module is an online module (COBOL + DB2 + CICS). In that case, RCT entries also require to execute the module after bound it to the package.

BIND to PACKAGE JCL -


Note! Below BIND PACKAGE JCL works as it is when you change your project-specific utility libraries and DBRM libraries.

Code -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//MTH001B JOB MSGLEVEL=(1,1),NOTIFY=&SYSUID                             
//**********************************************************************
//*  DB2 BIND JCL                                                       
//**********************************************************************
//BIND     EXEC PGM=IKJEFT01                                            
//STEPLIB  DD  DISP=SHR,DSN=XXXXXX.DBAG.SDSNEXIT                        
//         DD  DISP=SHR,DSN=XXXXXX.SDSNLOAD                             
//DBRMLIB  DD  DSN=MTH001.COBDB2.DBRMLIB,DISP=SHR                       
//SYSPRINT DD  SYSOUT=*                                                 
//SYSTSPRT DD  SYSOUT=*                                                 
//SYSUDUMP DD  SYSOUT=*                                                 
//SYSTSIN  DD  *                                                        
DSN SYSTEM (system-name)                                                
BIND  PACKAGE   (package-name)      -                                   
      MEMBER    (program-name)      -                                   
      ACTION    (action-options)    -                                   
      ISOLATION (isolation-options) -                                   
      VALIDATE  (validate-options)  -                                   
      RELEASE   (release-options)   -                                   
      EXPLAIN   (explain-options)   -                                   
      OWNER     (owner-id)          -                                   
      QUALIFIER (qualifier-name)    -                                   
      ENCODING  (encoding-options)                                      
END                                                                     
/*                                                                      
**************************** Bottom of Data ****************************

BIND to PLAN JCL -


Note! Below BIND PLAN JCL works as it is when you change your project-specific utility libraries and DBRM libraries.

Code -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//MTH001B JOB MSGLEVEL=(1,1),NOTIFY=&SYSUID                             
//**********************************************************************
//*  DB2 BIND JCL                                                       
//**********************************************************************
//BIND     EXEC PGM=IKJEFT01                                            
//STEPLIB  DD  DISP=SHR,DSN=XXXXXX.DBAG.SDSNEXIT                        
//         DD  DISP=SHR,DSN=XXXXXX.SDSNLOAD                             
//DBRMLIB  DD  DSN=MTH001.COBDB2.DBRMLIB,DISP=SHR                       
//SYSPRINT DD  SYSOUT=*                                                 
//SYSTSPRT DD  SYSOUT=*                                                 
//SYSUDUMP DD  SYSOUT=*                                                 
//SYSTSIN  DD  *                                                        
DSN SYSTEM (system-name)                                                
BIND  PLAN      (plan-name)         -                                   
      MEMBER    (program-name)      -                                   
      ACTION    (action-options)    -                                   
      ISOLATION (isolation-options) -                                   
      VALIDATE  (validate-options)  -                                   
      RELEASE   (release-options)   -                                   
      EXPLAIN   (explain-options)   -                                   
      OWNER     (owner-id)          -                                   
      QUALIFIER (qualifier-name)    -                                   
      ENCODING  (encoding-options)                                      
END                                                                     
/*                                                                      
**************************** Bottom of Data ****************************

MEMBER (program-name) -

  • MEMBER is the name of the DBRM member used for the application program in the DBRM library.

PACKAGE (package-name) -

  • Package contains optimized access path (OAP) that is generated by optimizer of BIND Process.
  • The package is a non-executable component and can contain one or more DBRMs.
  • The package is an intermediate component between the DBRM and PLAN.
  • The package's main advantage is that the rebound is not required when any change in the sub-program. Compiling subprogram is sufficient.

PLAN (plan-name) -

  • The plan also contains an optimized access path (OAP).
  • The plan is an executable component and used to execute the program.
  • The plan has the best access path to retrieve the data from the database by using the SQLs coded in the application program.

ACTION (action-options) -

  • The ACTION option defines whether the plan or package replaces an existing one with the same name or is new.
  • The available options are REPLACE and ADD.

ISOLATION (isolation-options) -

  • The ISOLATION option defines how far to isolate an application/application program from the effects of other running applications/application programs.
  • The Isolation level is the way to maintain the concurrency for various users by setting the levels of access to the database.
  • ISOLATION is the BIND parameter that determines the page lock duration.
  • Types of isolation levels -
    1. Cursor Stability (CS)
    2. Repeatable Read (RR)
    3. Read Stability (RS)
    4. Uncommitted Read (UR)/Dirty Read (DR)

Isolation level can explain in detail in seperate topic.

VALIDATE (validate-options) -

  • VALIDATE option specifies that BIND or REBIND errors should revalidate while the program runs.
  • The error types are "OBJECT NOT FOUND" and "NOT AUTHORIZED".
  • The validate-options are RUN and BIND.

RELEASE (release-options) -

  • The RELEASE option is used to decide when to release resources that are used by the program.
  • They are releasing the resource either at each commit point or when the program terminates.
  • The validate-options are COMMIT and DEALLOCATE.

EXPLAIN (explain-options) -

  • The EXPLAIN option is used to obtain information about how SQL statements are executed in the package or plan.
  • The available options are - NO and YES.

OWNER (owner-id) -

  • The OWNER option specifies the owner authorization id of the plan or package.
  • The owner should have the required privileges to execute the SQL statements from the program.

QUALIFIER (qualifier-name) -

  • The QUALIFIER specifies the implicit qualifier for the tables, views, indexes, and aliases in the plan or package.
  • The qualifier is mainly used when performing BIND for remote systems.

ENCODING (encoding-options) -

  • The ENCODING option specifies application encoding for all host variables used in SQL statements in plan or package.
  • The available options are - ASCII, EBCDIC, UNICODE, and ccsid.

LIB -

  • LIB is the library that specifies the partitioned dataset where the DBRMs are stored.
  • If the DBRMLIB is not specified explicitly in the JCL, the LIB option with the DBRM library in the BIND command is required.
  • If the DBRMLIB is specified explicitly, the LIB option with the DBRM library in the BIND command is not required.

Runtime Supervisor -

  • 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) & object code of DB2 (T2).
  • If T1=T2, the program is ready for execution.
  • If T1!=T2, the program ABENDs with -818 (timestamp mismatch error).

Practical Example -


Scenario - JCL to bind the COBOL + DB2 program.

Input required -

  • DBRMLIB - MATEGJ.COBDB2.DBRMLIB
  • PLAN - MATEGJC

BIND JCL -

----+----1----+----2----+----3----+----4----+----5----+----6----+----7--
***************************** Top of Data ******************************
//MATEGJB JOB MSGLEVEL=(1,1),NOTIFY=&SYSUID                             
//**********************************************************************
//*  DB2 BIND JCL                                                       
//**********************************************************************
//BIND     EXEC PGM=IKJEFT01                                            
//STEPLIB  DD  DISP=SHR,DSN=XXXXXX.DBAG.SDSNEXIT                        
//         DD  DISP=SHR,DSN=XXXXXX.SDSNLOAD                             
//DBRMLIB  DD  DSN=MATEGJ.COBDB2.DBRMLIB,DISP=SHR                       
//SYSPRINT DD  SYSOUT=*                                                 
//SYSTSPRT DD  SYSOUT=*                                                 
//SYSUDUMP DD  SYSOUT=*                                                 
//SYSTSIN  DD  *                                                        
DSN SYSTEM (DBAG)                                                    
BIND  PLAN      (MATEGJC) -                                            
      MEMBER    (SELECT1) -                                           
      ACTION    (REP)     -                                           
      ISOLATION (CS)      -                                           
      VALIDATE  (BIND)    -                                           
      RELEASE   (COMMIT)  -                                           
      OWNER     (MATEGJ)  -                                            
      QUALIFIER (MATEGJ)  -                                            
      ENCODING  (1047)                                                  
 END                                                                     
 /*                                                                      
 **************************** Bottom of Data ****************************

JOB Result - MAXCC

BIND JOB MAXCC

JOB Result - BIND Step

BIND JOB Precompile Step

JOB Result - BIND Step Final Report

BIND JOB Precompile Step Result