REBIND PACKAGE (DSN)

The DSN subcommand REBIND PACKAGE rebinds an application package when you make changes that affect the package, but have not changed the SQL statements in the program.

For example, you can use REBIND PACKAGE after you complete the following activities:

  • Migrate to a new DB2® release
  • Apply maintenance to DB2
  • Modify authorizations
  • Create a new index that statements in the package can use
  • Collect statistics using the RUNSTATS utility or with another utility by using the STATISTICS keyword

When the REBIND PACKAGE(*) command is issued, trigger packages are not affected.

REBIND PACKAGE is generally faster and more economical than BIND PACKAGE. You should use BIND PACKAGE with the ACTION(REPLACE) option under the following conditions:
  • When you change the SQL statements
  • When you recompile the program
  • When you have previously run BIND PACKAGE with the SQLERROR(CONTINUE) option

Environment

You can use REBIND PACKAGE through DB2I, or enter the REBIND PACKAGE subcommand from a DSN session running in foreground or background.

Data sharing scope: Group

Authorization

The package owner must have authorization to execute all SQL statements embedded in the package for REBIND PACKAGE to build a package without producing error messages. For VALIDATE(BIND), DB2 verifies the authorization at bind time. For VALIDATE(RUN), DB2 verifies the authorization initially at bind time, but if the authorization check fails, DB2 rechecks it at run time.

Start of changeWhen the EXPLAIN(ONLY) the option is specified, you must have the EXPLAIN privilege.End of change

The package owner must be a role to execute REBIND PACKAGE in a trusted context with role ownership.

The following table explains the authorization required to run REBIND PACKAGE, depending on the options specified.

Table 1. Summary of privileges for REBIND PACKAGE
Option Authorization required to run REBIND PACKAGE
REBIND PACKAGE with no change in ownership because the OWNER keyword is not specified. The authorization IDs of the process must have one of the following authorities:
  • Ownership of the package
  • BIND privilege on the package
  • BINDAGENT privilege from the owner of the package
  • PACKADM authority on the collection or on all collections
  • Start of changeSYSADM or SYSCTRL or System DBADM authorityEnd of change
REBIND PACKAGE with no change in ownership, although the original owner is specified for the OWNER keyword. The authorization IDs of the process must have one of the following authorities:
  • OWNER authorization-id must be one of the primary or secondary authorization IDs of the binder
  • BINDAGENT privilege from the owner of the package
REBIND PACKAGE with change of ownership. (An authorization ID that is not the original owner is specified in the OWNER keyword.) The new OWNER must have one of the following authorities:
  • BIND privilege on the package
  • PACKADM authority on the collection or on all collections
  • Start of changeSYSADM or SYSCTRL or System DBADM authorityEnd of change

Specifying the OWNER: If any of the authorization IDs have the BINDAGENT privilege granted from the owner, the authorization-id can specify the grantor as OWNER. Otherwise, OWNER authorization-id must be one of the primary or secondary authorization IDs of the binder.

Syntax

>>-REBIND PACKAGE--| ID-block |--+-------------------------+---->
                                 '-OWNER(authorization-id)-'   

>--+---------------------------+-------------------------------->
   '-QUALIFIER(qualifier-name)-'   

>--| enable-block |--| Start of changeoptions-blockEnd of change |-->

>--+------------------------+--+------------------------+------->
   '-CURRENTDATA(-+-YES-+-)-'  '-DBPROTOCOL(---DRDA---)-'   
                  '-NO--'                                   

>--+------------------------+--+-------------------+------------>
   +-DEFER(PREPARE)---------+  '-DEGREE(-+-1---+-)-'   
   +-DEFER(INHERITFROMPLAN)-+            '-ANY-'       
   '-NODEFER(PREPARE)-------'                          

>--+----------------------------+------------------------------->
   '-DYNAMICRULES(-+-RUN----+-)-'   
                   +-BIND---+       
                   +-DEFINE-+       
                   '-INVOKE-'       

>--+-------------------------+--+---------------------+--------->
   '-ENCODING(-+-ASCII---+-)-'  '-EXPLAIN(-+-YES--+-)-'   
               +-EBCDIC--+                 +-NO---+       
               +-UNICODE-+                 '-ONLY-'       
               '-ccsid---'                                

>--+---------------+--+----------------------------+------------>
   |       .-I-.   |  '-GETACCELARCHIVE(-+-----+-)-'   
   '-FLAG(-+-W-+-)-'                     +-NO--+       
           +-E-+                         '-YES-'       
           '-C-'                                       

>--+-----------------------------------+------------------------>
   |             .-INHERITFROMPLAN-.   |   
   '-IMMEDWRITE(-+-NO--------------+-)-'   
                 '-YES-------------'       

>--+---------------------+--+------------------------+---------->
   '-ISOLATION(-+-RR-+-)-'  |              .-NO--.   |   
                +-RS-+      '-KEEPDYNAMIC(-+-YES-+-)-'   
                +-CS-+                                   
                +-UR-+                                   
                '-NC-'                                   

>--+-------------------------+--+--------------------+---------->
   |               (1)       |  '-OPTHINT('hint-id')-'   
   |        .-NONE-------.   |                           
   |        |        (2) |   |                           
   '-REOPT(-+-ALWAYS-----+-)-'                           
            +-ONCE-------+                               
            '-AUTO-------'                               

>--+-----------------------------+--+-----------------+--------->
   |       .-,---------------.   |  |             (3) |   
   |       V                 |   |  '-PATHDEFAULT-----'   
   '-PATH(---+-schema-name-+-+-)-'                        
             '-USER--------'                              

>--+---------------------------------------------+-------------->
   '-QUERYACCELERATION(-+--------------------+-)-'   
                        +-NONE---------------+       
                        +-ENABLE-------------+       
                        +-ENABLEWITHFAILBACK-+       
                        +-ELIGIBLE-----------+       
                        '-ALL----------------'       

>--+--------------------------------+--------------------------->
   '-RELEASE(-+-COMMIT----------+-)-'   
              +-DEALLOCATE------+       
              '-INHERITFROMPLAN-'       

>--+------------------------+--+----------------------+--------->
   '-SWITCH(-+-PREVIOUS-+-)-'  '-VALIDATE(-+-RUN--+-)-'   
             '-ORIGINAL-'                  '-BIND-'       

>--+------------------------------+----------------------------->
   '-EXTENDEDINDICATOR(-+-NO--+-)-'   
                        '-YES-'       

>--+---------------------------------------------------------+-->
   '-CONCURRENTACCESSRESOLUTION(-+-USECURRENTLYCOMMITTED-+-)-'   
                                 '-WAITFOROUTCOME--------'       

>--+---------------------+-------------------------------------><
   '-GENERIC(-'string'-)-'   

Notes:
  1. NOREOPT(VARS) can be specified as a synonym of REOPT(NONE)
  2. REOPT(VARS) can be specified as a synonym of REOPT(ALWAYS)
  3. The PATHDEFAULT keyword is mutually exclusive with the PATH keyword. Do not specify both keywords in the same REBIND command.
Read syntax diagram
ID-block

       .-,-------------------------------------------------------------------------------.       
       V                                                                                 |       
>>-(-+---+---------------+-.-+-collection-id-+-.-+-package-id-+-.-+--------------------+-+-+-)-><
     |   '-location-name-'   '-*-------------'   '-*----------'   '-(-+------------+-)-'   |     
     |                                                                +-version-id-+       |     
     |                                                                '-*----------'       |     
     '-*-----------------------------------------------------------------------------------'     

enable-block

>>-+--------------------------------------------------------------------------------+-><
   |                  .-,------------.      .-------------------------------------. |   
   |                  V              |      V                                     | |   
   '-+-+-ENABLE--+--(---+-BATCH----+-+-)-+----+---------------------------------+-+-'   
     | '-DISABLE-'      +-DLIBATCH-+     |    |           .-,---------------.   |       
     |                  +-DB2CALL--+     |    |           V                 |   |       
     |                  +-CICS-----+     |    +-DLIBATCH(---connection-name-+-)-+       
     |                  +-IMS------+     |    |       .-,------.                |       
     |                  +-IMSBMP---+     |    |       V        |                |       
     |                  +-IMSMPP---+     |    +-CICS(---applid-+-)--------------+       
     |                  +-REMOTE---+     |    |         .-,-----.               |       
     |                  '-RRSAF----'     |    |         V       |               |       
     '-ENABLE(*)-------------------------'    +-IMSBMP(---imsid-+-)-------------+       
                                              |         .-,-----.               |       
                                              |         V       |               |       
                                              '-IMSMPP(---imsid-+-)-------------'       

options-block

>>-+--------------------------+--+----------------------+------->
   '-PLANMGMT(-+-BASIC----+-)-'  |          .-NONE--.   |   
               +-EXTENDED-+      '-APREUSE(-+-ERROR-+-)-'   
               '-OFF------'                                 

>--+------------------------+--+------------------------+------><
   |            .-NONE--.   |  |              .-YES-.   |   
   '-APCOMPARE(-+-WARN--+-)-'  '-APRETAINDUP(-+-NO--+-)-'   
                '-ERROR-'                                   

Option descriptions

For descriptions of the options shown in the syntax diagram, see the topic BIND and REBIND options for packages and plans.

Usage notes

Rebinding multiple packages: If you rebind multiple packages, DB2 commits each successful rebind before rebinding the next package.

Rebinding a package for a native SQL procedure: Start of changeIf you issue a REBIND PACKAGE command against a native SQL procedure package, the only bind options that you can change are EXPLAIN, PLANMGMT, SWITCH, APRETAINDUP, APREUSE, and APCOMPARE.End of change If you try to change other bind options the command will fail and return message DSNT215I. The REBIND PACKAGE command rebinds only the SQL statements included in the procedure and not the control statements in the procedure definition.

Start of changeRebinding a package for an SQL function: If you issue a REBIND PACKAGE command against a package for an SQL function, the only bind options that you can change are EXPLAIN, PLANMGMT, and SWITCH. If you try to change other bind options, the command will fail and return message DSNT215I. The REBIND PACKAGE command rebinds only the SQL statements included in the function and not the control statements in the function definition.End of change

Example

Rebind packages TEST.DSN8BC81.(MAY_VERSION) and PRODUCTION.DSN8BC81.(DEC_VERSION), both of which are located at the local location USIBMSTODB22. The packages can run only from the CICS® or the DLIBATCH environments if the connection ID is CON2. This replaces the CON1 that is specified on the BIND PACKAGE command.
REBIND PACKAGE (USIBMSTODB22.TEST.DSN8BC81.(MAY_VERSION),
                USIBMSTODB22.PRODUCTION.DSN8BC81.(DEC_VERSION)) -
  ENABLE (CICS,DLIBATCH) CICS (CON2)