Let's understand Mainframe
Home Tutorials Interview Q&A Quiz Mainframe Memes Contact us About us

Module 9: DB2 COBOL Programming


DBRM

DBRM (Database Request Module) is the file the DB2 precompiler extracts from your program. It holds all the SQL statements, and it is the input to the BIND process that creates the plan or package the program runs with.

What is a DBRM

  • A DBRM is a module containing the SQL statements from the source program, extracted by the DB2 precompiler.
  • It is stored as a member of a partitioned dataset (the DBRM library).
  • One DBRM is created for every program. If a main program calls n subprograms, there are n+1 DBRMs.
  • The DBRM is used as input to the BIND process. The DBRMs can be bound directly into a single plan, or each DBRM can become a package and the packages listed in a plan's PKLIST.
  • Each DBRM carries a timestamp. If the timestamp in the load module and the plan do not match, the program ends with SQLCODE -818.

The BIND process

  • BIND reads the SQL statements from the DBRMs and produces the mechanism DB2 uses to access the data.
  • During bind, DB2 checks the SQL for errors using the DB2 catalog, checks authorization and privileges, and lets the DB2 optimizer choose the access path.
  • The chosen access strategies are stored as a PLAN or PACKAGE, so they are reusable without repeating the bind.
  • There are two types of bind: BIND PLAN and BIND PACKAGE.
  • Important bind parameters: MEMBER (the DBRM to bind) and LIB (the DBRM library); VALIDATE (BIND or RUN handling of object-not-found errors); ISOLATION (CS, RR, UR lock duration); ACTION (ADD or REPLACE); QUALIFIER; EXPLAIN; SQLERROR.

Keeping DBRM, plan and load module in sync

  • Recompile means re-precompile, which means a new DBRM timestamp - so rebind every time you recompile.
  • When a program calls subprograms, bind every DBRM (all n+1), otherwise calls fail with -805.
  • Use the QUALIFIER bind parameter to move a program between regions (test to production) without changing the source.

Example of a BIND JCL card:-

//BIND EXEC PGM=IKJEFT01 //SYSTSPRT DD SYSOUT=* //SYSTSIN DD * DSN SYSTEM(DB2P) BIND PLAN(EMPPLAN) MEMBER(EMPDBRM) VALIDATE(BIND) ISOLATION(CS) RELEASE(COMMIT) OWNER(MYID) LIB('MYID.DBRM.LIB') END /*





© copyright mainframebug.com
Privacy Policy
MainframeBug Assistant