Program preparation on DB2 for z/OS ends with DSN subcommands, not with the compiler. This page is the command map for the six statements you will type (or generate in JCL) for packages, plans, basic triggers, and REST services: BIND PACKAGE, BIND PLAN, REBIND PACKAGE, REBIND PLAN, REBIND TRIGGER PACKAGE, and BIND SERVICE. Later pages in this chapter drill into individual bind options.
These are DSN subcommands. Issue them from:
Data sharing scope is group: bind once, every member can use the package or plan. IFCID 090 on other members may show SYSOPR running the same command. They are not -BIND operator commands and not utilities.
| Subcommand | When you use it | Result |
|---|---|---|
| BIND PACKAGE | New or changed DBRM, new version, COPY into a collection | Package in catalog + directory; deletes phased-out copies |
| BIND PLAN | Create/replace the runtime plan and PKLIST | Application plan required to allocate Db2 |
| REBIND PACKAGE | SQL unchanged; stats, indexes, options, or invalid package | New current copy; PLANMGMT may keep previous/original |
| REBIND PLAN | Change plan attributes or package list | Updated plan; packages themselves unchanged unless MEMBER used |
| REBIND TRIGGER PACKAGE | Basic trigger needs a new path or option; invalid trigger package | Rebound basic trigger package (VALID after success) |
| BIND SERVICE | Create or replace a native REST service | REST package + DSNSERVICE row |
Builds an application package. Db2 records the description in the catalog and saves the prepared package in the directory. BIND PACKAGE also deletes phased-out package copies. Identify the package by collection (required) and, from the DBRM, package-id and version. Optional location-name binds at a remote server.
123456DSN SYSTEM(DB2A) BIND PACKAGE(PAYROLL) MEMBER(PAYCALC) - ACTION(REPLACE) OWNER(PAYBIND) QUALIFIER(HR) - ISOLATION(CS) RELEASE(COMMIT) VALIDATE(BIND) - EXPLAIN(YES) CURRENTDATA(NO) PLANMGMT(EXTENDED) END
The package owner must be authorized to execute the embedded SQL or BIND produces errors (SYSADM and DATAACCESS include that). Adding a package depends on subsystem parameter BINDNV: the BINDADD path needs BINDADD plus CREATE IN or PACKADM; if BINDNV is BIND, PACKADM or BIND on the collection can add a new version of an existing package. REPLACE needs ownership, BIND on the package, PACKADM, or a system authority. EXPLAIN(ONLY) needs the EXPLAIN privilege; SQLERROR(CHECK) needs BIND, BINDAGENT, or EXPLAIN.
Each package contains one DBRM. You do not BIND PACKAGE for a program whose only SQL is SET CURRENT PACKAGESET. Trigger packages are not created with this command.
Builds the application plan every program needs in order to allocate Db2 resources at run time. Modern syntax is PKLIST, not a pile of DBRMs.
123456BIND PLAN(PAYPLAN) - PKLIST(PAYROLL.*, COMMON.*) - ACTION(REPLACE) RETAIN - ISOLATION(CS) RELEASE(COMMIT) - OWNER(PAYBIND) QUALIFIER(HR) - CACHESIZE(1024)
The MEMBER option is deprecated. If you specify it, Db2 binds those DBRMs into packages and includes them in a package list. Use BIND PACKAGE plus PKLIST unless you cannot. ACTION(ADD) needs BINDADD (or SYSADM / SYSCTRL / system DBADM). ACTION(REPLACE) RETAIN keeps EXECUTE privileges. ENABLE/DISABLE restrict environments (CICS, IMS, BATCH, RRSAF, and so on). Plans are bound locally even when PKLIST names remote packages; bind those packages at the remote location.
Rebinds an application package when you make changes that affect the package but have not changed the SQL statements in the program. Examples: CREATE INDEX, RUNSTATS, changing ISOLATION, validating an invalid package. If the SQL changed, use BIND PACKAGE ACTION(REPLACE) with a new DBRM instead.
1234567REBIND PACKAGE(PAYROLL.PAYCALC) - APREUSE(WARN) APCOMPARE(WARN) - PLANMGMT(EXTENDED) EXPLAIN(YES) REBIND PACKAGE(PAYROLL.*) ISOLATION(CS) REBIND PACKAGE(PAYROLL.PAYCALC) SWITCH(PREVIOUS)
You can change any bind option on an ordinary package. Wildcards rebind local packages you are authorized to bind; an asterisk does not apply to remote packages. SWITCH (PREVIOUS | ORIGINAL) makes a PLANMGMT copy current without a full re-optimize — the standard backout after a bad rebind. Autobind, if it runs, replaces only the current copy.
Rebinds an application plan when you change attributes such as the package list. You can change any plan bind options.
12REBIND PLAN(PAYPLAN) PKLIST(PAYROLL.*, COMMON.*, AUDIT.*) REBIND PLAN(PAYPLAN) NOPKLIST
Rebinding the plan does not rebind every package on the list. If you need new access paths for the programs, REBIND PACKAGE (possibly with collection.*) as a separate step.
Rebinds a package for a basic trigger. Query SYSIBM.SYSTRIGGERS: blank SQLPL means basic. For advanced triggers, use REBIND PACKAGE instead. A trigger package can be explicitly rebound but cannot be explicitly bound with BIND PACKAGE — you create a new trigger package by recreating the trigger.
Use REBIND TRIGGER PACKAGE when you create a new index the trigger SQL should use, or when the trigger package is invalid because a dependent object changed. Success marks the package valid. REBIND TRIGGER PACKAGE(*) affects only basic trigger packages you are authorized to rebind.
12REBIND TRIGGER PACKAGE(PAYROLL.TRIGPAY1) - EXPLAIN(YES) ISOLATION(CS) RELEASE(COMMIT)
The documented option subset includes CURRENTDATA, DESCSTAT, EXPLAIN, FLAG, IMMEDWRITE, ISOLATION, RELEASE, SWITCH, CONCURRENTACCESSRESOLUTION, temporal/archive sensitive options, and APPLCOMPAT. You do not get the full BIND PACKAGE option list (for example QUALIFIER on a trigger is not the COBOL-style replace-bind story).
Builds an application package that represents a Db2 native REST service. Db2 records the service in catalog tables (SYSIBM.DSNSERVICE) and saves the prepared package in the directory. The SQL is one static statement (SELECT, INSERT, UPDATE, DELETE, TRUNCATE, CALL, or WITH) supplied on SQLDDNAME or via the createService API.
12345BIND SERVICE(PAYROLL) NAME(getEmp) - SQLDDNAME(SQLIN) - DESCRIPTION('Employee by empno') - OWNER(PAYBIND) QUALIFIER(HR) - ISOLATION(CS) APPLCOMPAT(V12R1M500)
Service-specific options include NAME, DESCRIPTION, VERSION, SQLDDNAME, and SQLENCODING. Other options match BIND PACKAGE. Authorization follows BIND PACKAGE rules for ADD versus REPLACE, plus the owner must be able to execute the embedded SQL. After bind, the package is executed as a REST service through DDF — not as a normal application CALL. Drop the active service with FREE SERVICE, not FREE PACKAGE on the active copy (inactive PLANMGMT copies can still be freed with FREE PACKAGE and PLANMGMTSCOPE).
Triggers skip steps 1–2: CREATE TRIGGER built the package. REST services skip the COBOL precompile: BIND SERVICE is the bind. BIND QUERY is a seventh cousin for statement-level hints (DSN_USERQUERY_TABLE → SYSQUERY*); it is not required for ordinary COBOL packages.
BIND PACKAGE is cooking a new meal from a recipe card (DBRM) and putting it on a shelf (collection). BIND PLAN is printing the cafeteria ticket that lists shelves. REBIND PACKAGE is recooking the same recipe because you bought a new oven (statistics) or a new pan (index). REBIND PLAN is reprinting the ticket with different shelves. REBIND TRIGGER PACKAGE is recooking the automatic “when someone touches the cookie jar” recipe; you are not allowed to cook that one from a COBOL card. BIND SERVICE is wrapping one meal so a phone app can order it over the internet instead of sitting in the dining room.
1. Which six DSN subcommands does this prepare chapter treat as the core BIND/REBIND set?
2. Can you BIND PACKAGE a basic trigger?
3. What does BIND SERVICE create?
4. BIND PLAN MEMBER is:
5. What is the data-sharing scope of these subcommands?