Binding application packages and plans
You must bind the DBRM that is produced by the SQL statement processor to a package before your Db2 application can run. The bind process establishes a relationship between an application program and its relational data.
Before you begin
You must have appropriate privileges. For more information, see Privileges required for handling plans and packages
About this task
During the precompilation process, the Db2 precompiler produces both modified source code and a database request module (DBRM) for each application program. The modified source code must be compiled and link-edited before the program can be run. DBRMs must be bound to a package. You can then associate that package with a particular application plan.
During the bind process, Db2 also completes the following actions:
- Validates object references in the SQL statements of the program, such as table, view, and column names, against the Db2 catalog. Because the bind process occurs before program execution, errors are detected and can be corrected before the program is executed.
- Verifies the authorization of the bind process to specify the program owner and the authorization of the specified owner to access data that is requested by SQL statements in the program.
- Selects the access paths that Db2 uses to access data for the program. Db2 considers factors such as table size, available indexes, and others, when selecting the access paths.
When determining the maximum size of a plan, you must consider several physical limitations, including the time required to bind the plan, the size of the EDM pool, and fragmentation. As a general rule, the EDM pool should be at least 10 times the size of the largest DBD or plan, whichever is greater.
Each package that you bind can contain only one DBRM.
Because you do not need a plan or package to execute the SET CURRENT PACKAGESET statement, the ENCODING bind option does not affect the SET CURRENT PACKAGESET statement. An application that needs to provide a host variable value in an encoding scheme other than the system default encoding scheme must use the DECLARE VARIABLE statement to specify the encoding scheme of the host variable.
You must bind plans locally, regardless of whether they reference packages that run remotely. However, you must bind the packages that run at remote locations at those remote locations.
From a Db2 requester, you can run a plan by specifying it in the RUN subcommand, but you cannot run a package directly. You must include the package in a plan and then run the plan.
Procedure
To bind application programs, take the following actions.