Rebinding a package

You need to rebind a package when you make changes that affect the package but that do not involve changes to the SQL statements. For example, if you create a new index, you need to rebind the package. If you change the SQL, you need to use the BIND PACKAGE command with the ACTION(REPLACE) option.

About this task

To rebind a package, other than a trigger package, use the REBIND subcommand. To rebind a trigger package, use the REBIND TRIGGER PACKAGE subcommand. You can change any of bind options for a package when you rebind it.

The following table clarifies which packages are bound, depending on how you specify collection-id (coll-id), package-id (pkg-id), and version-id (ver-id) on the REBIND PACKAGE subcommand.

REBIND PACKAGE does not apply to packages for which you do not have the BIND privilege. An asterisk (*) used as an identifier for collections, packages, or versions does not apply to packages at remote sites.

Table 1. Behavior of REBIND PACKAGE specification. "All" means all collections, packages, or versions at the local DB2® server for which the authorization ID that issues the command has the BIND privilege.
Input Collections affected Packages affected Versions affected
*
all all all
*.*.(*)
all all all
*.*
all all all
*.*.(ver-id)
all all ver-id
*.*.()
all all empty string
coll-id.*
coll-id all all
coll-id.*.(*)
coll-id all all
coll-id.*.(ver-id)
coll-id all ver-id
coll-id.*.()
coll-id all empty string
coll-id.pkg-id.(*)
coll-id pkg-id all
coll-id.pkg-id
coll-id pkg-id empty string
coll-id.pkg-id.()
coll-id pkg-id empty string
coll-id.pkg-id.(ver-id)
coll-id pkg-id ver-id
*.pkg-id.(*)
all pkg-id all
*.pkg-id
all pkg-id empty string
*.pkg-id.()
all pkg-id empty string
*.pkg-id.(ver-id)
all pkg-id ver-id
Example: The following example shows the options for rebinding a package at the remote location. The location name is SNTERSA. The collection is GROUP1, the package ID is PROGA, and the version ID is V1. The connection types shown in the REBIND subcommand replace connection types that are specified on the original BIND subcommand.
REBIND PACKAGE(SNTERSA.GROUP1.PROGA.(V1)) ENABLE(CICS,REMOTE)

You can use the asterisk on the REBIND subcommand for local packages, but not for packages at remote sites. Any of the following commands rebinds all versions of all packages in all collections, at the local DB2 system, for which you have the BIND privilege.

REBIND PACKAGE (*)
REBIND PACKAGE (*.*)
REBIND PACKAGE (*.*.(*))

Either of the following commands rebinds all versions of all packages in the local collection LEDGER for which you have the BIND privilege.

REBIND PACKAGE (LEDGER.*)
REBIND PACKAGE (LEDGER.*.(*))

Either of the following commands rebinds the empty string version of the package DEBIT in all collections, at the local DB2 system, for which you have the BIND privilege.

REBIND PACKAGE (*.DEBIT)
REBIND PACKAGE (*.DEBIT.())