Module 12: DBRM, Package, Plan and DB2 JCL
BIND PACKAGE
BIND PACKAGE converts one DBRM into an executable package. It is the per-program bind you run every time a single program changes.
What BIND PACKAGE does
- It reads the SQL statements from the DBRM member in the DBRM library.
- It checks SQL syntax, verifies that objects exist (or defers the check with VALIDATE(RUN)), and checks your authorization.
- The DB2 optimizer chooses the access paths for every SQL statement.
- The result is stored as a package in the DB2 catalog, ready to be named in any plan's PKLIST.
When to use BIND PACKAGE
- Use it when you want per-program maintenance: rebind one program without touching the rest of the application.
- Standard practice is BIND PACKAGE for every program, then a single BIND PLAN with PKLIST.
- Run it after every change to the program's SQL, and after RUNSTATS or index changes that affect its tables.
Key BIND PACKAGE options
- ACTION(ADD | REPLACE) - add a new package or replace the existing one. REPLACE is the default.
- QUALIFIER - schema added to unqualified table and view names at bind time. Handy when promoting code across regions.
- ISOLATION(CS | RR | UR | RS) - how isolated the program is from other programs. CS (cursor stability) is the usual choice.
- EXPLAIN(YES | NO) - YES writes the chosen access paths into PLAN_TABLE for tuning. NO is the default.
- VALIDATE(BIND | RUN) - BIND checks objects and authorization now; RUN defers the check to execution time.
- SQLERROR(NOPACKAGE | CONTINUE) - NOPACKAGE (default) creates nothing if any SQL error occurs; CONTINUE creates the package anyway.
- OWNER - authorization ID that will own the package.
Example: full BIND PACKAGE job
- A complete batch job that binds DBRM member PROG1 into collection MYCOLL:
//BINDPKG JOB (ACCT),'BIND PKG',CLASS=A,MSGCLASS=X //BIND EXEC PGM=IKJEFT01,DYNAMNBR=20 //STEPLIB DD DSN=DB2A.SDSNLOAD,DISP=SHR //SYSTSPRT DD SYSOUT=* //SYSTSIN DD * DSN SYSTEM(DB2A) BIND PACKAGE (MYCOLL) MEMBER (PROG1) LIB ('USERID.DBRMLIB') ACTION (REPLACE) QUALIFIER (APPOWN) ISOLATION (CS) EXPLAIN (NO) END /*
