Binding an optimization profile to a package

When you prepare a package by using the BIND or PRECOMPILE command, you can use the OPTPROFILE command parameter to specify the optimization profile for the package.

About this task

This method is the only way to apply an optimization profile to static statements, and the specified profile applies to all static statements in the package. An optimization profile that is specified in this manner is also the default optimization profile that is used for dynamic statements within the package.

Procedure

You can bind an optimization profile in SQLJ or embedded SQL using APIs (for example, sqlaprep) or the command line processor (CLP).
For example, the following code shows how to bind an inventory database optimization profile to an inventory application from the CLP:
   db2 prep inventapp.sqc bindfile optprofile newton.inventdb
   db2 bind inventapp.bnd
   db2 connect reset
   db2 terminate
   xlc -I$HOME/sqllib/include -c inventapp.c -o inventapp.o
   xlc -o inventapp inventapp.o -ldb2 -L$HOME/sqllib/lib

If you do not specify a schema name for the optimization profile, the QUALIFIER command parameter is used as the implicit qualifier.