Packages and application plans

A package contains control structures that DB2 uses when it runs SQL statements. 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 relates an application process to a local instance of DB2, specifies processing options, and contains one or both of the following elements:

  • A list of package names

  • The bound form of SQL statements

Most DB2 applications require an application plan. Packages make application programs more flexible and easier to maintain. For example, when you use packages, you do not need to bind the entire plan again when you change one SQL statement.

Example: Figure 2.7 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.

Figure 2.7. Application plan and packages


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 book.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.156.202