Static SQL in DB2 for z/OS is not authorized the way a desktop database authorizes a user who types SELECT. The package owner needed table privileges at BIND time. At run time, the person who presses Enter needs EXECUTE on the plan (and the plan needs to be allowed to use its packages). This page lists every package and plan privilege, shows GRANT and REVOKE forms, and explains PACKADM and collection wildcards.
A package is the bound form of SQL from one DBRM (one program or one version of a program) in a collection. A plan is what a TSO CALL, batch IKJEFT01, CICS RCT entry, or similar attachment actually runs. The plan’s PKLIST names the packages it may use.
If every teller needed SELECT, UPDATE, and INSERT on BANK.ACCOUNT, you would be granting table access to hundreds of IDs — and they could use SPUFI, not only the teller program. Instead you bind the teller program so the owner has the table privileges, then:
12GRANT EXECUTE ON PLAN TELLPLAN TO TELLGRP; GRANT EXECUTE ON PACKAGE TELLCOLL.* TO TELLGRP;
TELLGRP can run the application. They cannot open SPUFI and SELECT the whole account table unless you also granted table privileges. That separation is the whole point of plan and package EXECUTE.
Db2 for z/OS documents these explicit package privileges:
| Privilege | Object | Allows |
|---|---|---|
| BIND | Package | BIND, REBIND, FREE PACKAGE; DROP PACKAGE; new version if install option allows |
| COPY | Package | BIND PACKAGE with the COPY option |
| EXECUTE | Package | Run the package; include it in PKLIST subject to naming rules |
| ALL | Package | All package privileges the grantor holds on that package |
| BIND | Plan | BIND, REBIND, and FREE PLAN |
| EXECUTE | Plan | RUN the application that uses the plan |
123456789GRANT BIND, COPY, EXECUTE ON PACKAGE TELLCOLL.TELLPGM TO ROLE TELLER_ADMIN WITH GRANT OPTION; GRANT EXECUTE ON PACKAGE TELLCOLL.TELLPGM TO TELLGRP; GRANT ALL ON PACKAGE TELLCOLL.TELLPGM TO ROLE TELLER_ADMIN; REVOKE EXECUTE ON PACKAGE TELLCOLL.TELLPGM FROM TELLGRP;
You can grant to an authorization name, to ROLE role-name, or to PUBLIC. WITH GRANT OPTION lets the grantee pass the same privilege on. Only an explicit GRANT can be REVOKEd. If two grantors gave EXECUTE, both must revoke before the ID loses it.
Naming collection.* grants the privilege on every package in that collection, including packages bound later. That is the usual production pattern. Granting only collection.package-id is tighter but means every new program needs another GRANT.
12GRANT EXECUTE ON PACKAGE PAYROLL.* TO PAYBATCH; GRANT BIND ON PACKAGE PAYROLL.* TO ROLE PAY_BINDER;
You must hold the privilege WITH GRANT OPTION, or hold an authority that includes it (SYSADM, PACKADM on that collection, and similar). The binder / OWNER of a package receives package privileges as an owner. BINDAGENT lets one ID bind on behalf of another owner; the owner still needs the SQL privileges inside the package.
Plans have a shorter list:
1234567GRANT BIND, EXECUTE ON PLAN DSN8CP12 TO PUBLIC; GRANT EXECUTE ON PLAN DSN8CP12 TO ADAMSON, BROWN WITH GRANT OPTION; GRANT BIND ON PLAN PAYPLAN TO ROLE PAY_BINDER; REVOKE BIND ON PLAN PAYPLAN FROM ROLE PAY_BINDER;
BIND REPLACE on an existing plan can drop existing EXECUTE grants unless you use the BIND option that retains them. IBM warns that this default is easy to miss after a production rebind: yesterday’s tellers get SQLCODE -551 until you GRANT EXECUTE again. For packages, EXECUTE privileges are retained on replace.
BIND PLAN … PKLIST(TELLCOLL.*) does not magically give every future runner EXECUTE on every package. Two checks show up in real life:
Stored procedures are the textbook second GRANT. After CREATE PROCEDURE you typically:
123GRANT EXECUTE ON PROCEDURE BANK.GET_BAL TO TELLGRP; GRANT EXECUTE ON PACKAGE BANKAPP.GET_BAL TO TELLGRP; GRANT EXECUTE ON PACKAGE BANKAPP.GET_BAL TO ROLE ADMINISTRATOR;
DYNAMICRULES on the calling plan or package decides which ID or role must hold EXECUTE for a CALL. Native SQL procedures and external procedures both have a package that must be executable.
The collection itself has CREATE IN: permission to BIND PACKAGE into that collection (to name it). Without CREATE IN, BIND PACKAGE(TELLCOLL) fails even if you have BINDADD at the system level.
123GRANT CREATE IN ON COLLECTION TELLCOLL TO ROLE TELLER_ADMIN; GRANT PACKADM ON COLLECTION GOLFS TO PKA01 WITH GRANT OPTION;
PACKADM ON COLLECTION gives PKA01 package privileges on all packages in GOLFS plus CREATE IN on GOLFS. WITH GRANT OPTION lets PKA01 grant those to others. Shops often give PACKADM to a role that exists only in a bind trusted context, not to every developer’s TSO ID.
If RACF access control is active, the same privileges appear as resources in classes MDSNPK (packages) and MDSNPL (plans), for example DB2P.TELLCOLL.TELLPGM.EXECUTE. Native GRANT and RACF PERMIT must not silently disagree.
EXECUTE on the plan does not automatically authorize PREPARE of a dynamic SELECT the program builds at run time. Dynamic SQL uses DYNAMICRULES (RUN, BIND, DEFINE, INVOKE, and the *_SYS variants). Under RUN, the runner’s authorization ID (or role) needs the table privileges. Under BIND, the owner’s privileges are reused, which is powerful and must be designed on purpose. Do not assume “they only have EXECUTE” if the program issues dynamic SQL.
The package is a lunchbox the cook packed (BIND) using the cook’s kitchen keys (table privileges). The plan is the cafeteria tray that holds those lunchboxes. Kids in the lunch line do not get kitchen keys. They get a ticket that says they may carry that tray (EXECUTE ON PLAN) and sometimes a ticket for a particular lunchbox (EXECUTE ON PACKAGE). COPY is permission to photocopy a lunchbox into another fridge (another collection). BIND on an existing tray is permission to repack it, which can accidentally throw away old tickets unless you ask to RETAIN them.
1. What does EXECUTE on a plan allow?
2. Which package privileges exist in Db2 for z/OS?
3. Does the user who RUNS a COBOL program need SELECT on the tables?
4. What does GRANT EXECUTE ON PACKAGE PAYROLL.* TO TELLER do?
5. What extra privilege does PACKADM add beyond package EXECUTE?
GRANT EXECUTE TO ROLE and PACKADM as an authority you can put on a role
MDSNPK and MDSNPL resource names for the same BIND/COPY/EXECUTE checks
Which ID is the binder, owner, and runner for static versus dynamic SQL