After objects exist, DB2 for z/OS still has to remember how programs use them. Package, plan, and routine catalog tables describe binds, SQL text, stored procedures, functions, sequences, triggers, global variables, package privileges, and package dependencies. This is the catalog neighborhood you live in when VALID goes to N on a Monday morning.
A package is the bound form of a DBRM (or SQL PL routine) in a collection. A plan is the named executable a CICS RCT, TSO DSN, or IMS attach often specifies; today that plan usually lists packages rather than containing every SQL statement itself. The catalog mirrors that split: SYSPACKAGE / SYSPACKSTMT / SYSPACKDEP versus SYSPLAN / SYSSTMT. Directory spaces SPT01 and SCT02 hold the skeleton runtime copies; the catalog holds the descriptive rows you SELECT.
One row per package copy. Identify a package with LOCATION (blank for local), COLLID (collection), NAME, CONTOKEN (consistency token from precompile), and VERSION when you use versioned packages. OWNER, QUALIFIER, BINDTIME, ISOLATION, RELEASE, EXPLAIN, and DEGREE record bind options.
| VALID | Meaning |
|---|---|
| Y | Valid — runtime structures can be used |
| N | Invalid — typically needs rebind / autobind |
| S | Statement-level invalidation (recent function levels; package-level VALID on SYSPACKAGE) |
| OPERATIVE | Meaning |
|---|---|
| Y | Operative |
| N | Inoperative — autobind failed; bind must be corrected |
| R | Rebind-advisory (documented for some autobind phase-in cases) |
IBM documents that an automatic rebind is triggered when an authorized user runs a package whose runtime structures cannot be used—often after ALTER on a dependent object. VALID = N is the usual invalid flag. If autobind fails, OPERATIVE becomes N and you must fix the SQL or the objects and BIND/REBIND explicitly. Recent function levels add statement-level invalidation (VALID = S) and rebind-advisory OPERATIVE = R for some phase-in cases—check your function level before you write a monitor that only understands Y/N.
12345SELECT COLLID, NAME, VERSION, VALID, OPERATIVE, BINDTIME, ISOLATION FROM SYSIBM.SYSPACKAGE WHERE COLLID = 'HRCOLL' AND VALID <> 'Y' WITH UR;
One or more rows per static SQL statement in a package. Join to SYSPACKAGE on LOCATION, COLLID, NAME, CONTOKEN, and VERSION. Useful columns:
123456SELECT S.STMTNOI, S.QUERYNO, S.SECTNOI, SUBSTR(S.STATEMENT, 1, 80) AS SQL_START FROM SYSIBM.SYSPACKSTMT S WHERE S.COLLID = 'HRCOLL' AND S.NAME = 'HREMP' WITH UR;
SYSPLAN describes plans: NAME, CREATOR, VALID, OPERATIVE, BINDTIME, ISOLATION, and related bind options. SYSSTMT holds SQL text for DBRMs bound into plans the old way (PLNAME, NAME as DBRM, STMTNO, TEXT). If your shop is package-only, SYSPLAN rows still exist for the attach plan, but SYSSTMT may be sparse. SYSPLANDEP is the plan-side dependency table (cousin of SYSPACKDEP).
1234SELECT NAME, CREATOR, VALID, OPERATIVE, BINDTIME FROM SYSIBM.SYSPLAN WHERE NAME = 'HRPLAN' WITH UR;
SYSROUTINES has one row per user-defined function or stored procedure. SCHEMA + NAME + SPECIFICNAME identify overloads. OWNER, LANGUAGE (SQL, COBOL, JAVA, C, …), ORIGIN (external versus native SQL), and PARM_COUNT describe implementation.
| ROUTINETYPE | Meaning |
|---|---|
| F | Function |
| P | Stored procedure |
SYSPARMS has one row per parameter (and the function return value as a special row in IBM’s design). Join on SCHEMA, NAME, SPECIFICNAME (and ROUTINETYPE when present). ORDINAL, PARMNAME, TYPENAME, LENGTH, SCALE, and ROWTYPE-style columns tell you IN / OUT / INOUT. This is how you generate CALL stubs and audit Java signature drift.
12345678910111213SELECT R.SCHEMA, R.NAME, R.SPECIFICNAME, R.ROUTINETYPE, R.LANGUAGE, R.ORIGIN, R.PARM_COUNT FROM SYSIBM.SYSROUTINES R WHERE R.SCHEMA = 'HR' ORDER BY R.ROUTINETYPE, R.NAME WITH UR; SELECT PARMNAME, ORDINAL, TYPENAME, LENGTH, ROWTYPE FROM SYSIBM.SYSPARMS WHERE SCHEMA = 'HR' AND SPECIFICNAME = 'EMP_RAISE_SP' ORDER BY ORDINAL WITH UR;
One row per sequence object and, in IBM’s catalog design, also for identity-column sequences behind IDENTITY columns. SCHEMA and NAME identify the sequence. START, MINVALUE, MAXVALUE, INCREMENT, CYCLE, CACHE, and MAXASSIGNEDVAL (as documented for your release) describe numbering. SEQTYPE distinguishes an independent CREATE SEQUENCE from an identity-backed sequence. Sequence privileges live in SYSSEQUENCEAUTH (see the authorization page’s family, even though that table is not the focus there).
1234SELECT SCHEMA, NAME, INCREMENT, CYCLE, CACHE FROM SYSIBM.SYSSEQUENCES WHERE SCHEMA = 'HR' WITH UR;
One row per trigger. SCHEMA and NAME identify the trigger; TBOWNER and TBNAME identify the subject table. Typical attributes:
Statement text may be in SYSTRIGGERS or a companion SYSTRIGGERS_STMT table depending on release. Finding triggers on a table is a required impact step before ALTER or DROP:
12345SELECT SCHEMA, NAME, TRIGTIME, TRIGEVENT, GRANULARITY FROM SYSIBM.SYSTRIGGERS WHERE TBOWNER = 'HR' AND TBNAME = 'EMPLOYEE' WITH UR;
CREATE VARIABLE objects are cataloged here: schema, name, data type, default, and owner. Global variables are not host variables and not columns. Application teams discover them the same way they discover sequences—by querying the catalog—because they will not appear in SYSTABLES.
These are privilege tables for programs, not objects. SYSPACKAUTH records who (GRANTEE) received EXECUTE and related package privileges from GRANTOR, with the usual Y / G / blank encoding (held, held WITH GRANT OPTION, not held). Qualify by COLLID and NAME (and CONTOKEN/VERSION as required). SYSPLANAUTH is the same idea for plans (EXECUTE on the plan name). Collection-level CREATE IN / PACKADM style privileges are resource privileges in SYSRESAUTH, not these two tables.
12345SELECT GRANTEE, GRANTEETYPE, COLLID, NAME, EXECUTEAUTH FROM SYSIBM.SYSPACKAUTH WHERE COLLID = 'HRCOLL' AND NAME = 'HREMP' WITH UR;
SYSPACKDEP lists objects a package depends on. That is how Db2 knows to set VALID = N after DROP INDEX or ALTER TABLE. DNAME/DCOLLID identify the package; BCREATOR, BNAME, and BTYPE identify the base object.
| BTYPE | Object |
|---|---|
| T | Table |
| I | Index |
| V | View |
| S | Synonym |
| A / 0 | Alias (BTYPE values vary by table; confirm in SQL Reference) |
| F | Function |
| O | Procedure |
| Q | Sequence |
| E | INSTEAD OF trigger (on some dependency tables) |
123456SELECT DCOLLID, DNAME, BCREATOR, BNAME, BTYPE FROM SYSIBM.SYSPACKDEP WHERE BCREATOR = 'HR' AND BNAME = 'EMPLOYEE' AND BTYPE = 'T' WITH UR;
Run that query before you DROP a table: every package row is a bind you will break. Combine with SYSVIEWDEP and SYSTRIGGERS for a full impact list.
A package is a lunchbox of already-decided instructions for SQL. SYSPACKAGE is the label on the lunchbox (whose class, which kid, is the sandwich still good?). SYSPACKSTMT is the list of snacks inside. SYSPLAN is the cafeteria tray that can hold several lunchboxes. SYSROUTINES is the recipe book for special kitchen machines (procedures and functions). SYSPACKDEP is the note “this lunchbox needs the apple basket named EMPLOYEE”—if someone throws away the basket, the label switches to “not valid.”
1. How is a package identified in SYSPACKAGE?
2. VALID = 'N' on SYSPACKAGE typically means:
3. SYSROUTINES ROUTINETYPE = 'P' means:
4. What does SYSPACKDEP tell you?
5. SYSPACKSTMT versus SYSSTMT: