Packages and application plans

A package contains control structures that DB2® uses when it runs SQL statements. An application plan relates an application process to a local instance of DB2 and specifies processing options.

Packages are produced during program preparation. You can think of the control structures as the bound or operational form of SQL statements. All control structures in a package are derived from the SQL statements that are embedded in a single source program.

An application plan contains one or both of the following elements:

  • A list of package names

DB2 applications require an application plan. Packages make application programs more flexible and easier to maintain.

Example: The following figure shows an application plan that contains two packages. Suppose that you decide to change the SELECT statement in package AA to select data from a different table. In this case, you need to bind only package AA again and not package AB.
Begin general-use programming interface information.
Figure 1. Application plan and packages
Begin figure description. Plan A contains packages AA and AB. In package AA the SQL statement changed from "SELECT * FROM TABLET" to "SELECT * FROM TABLE3". End figure description.
End general-use programming interface information.

In general, you create plans and packages by using the DB2 commands BIND PLAN and BIND PACKAGE.

A trigger package is a special type of package that is created when you execute a CREATE TRIGGER statement. A trigger package executes only when the trigger with which it is associated is activated.

Packages for JDBC, SQLJ, and ODBC applications serve different purposes that you can read more about later in this information.