Bind options for remote access

Binding a package to run at a remote location is like binding a package to run at your local Db2 subsystem. Binding a plan to run the package is like binding any other plan. However, a few differences exist.

For the general instructions, see Preparing an application to run on Db2 for z/OS.

BIND PLAN options for DRDA access

The following options of BIND PLAN are particularly relevant to binding a plan that uses DRDA access:
DISCONNECT
For most flexibility, use DISCONNECT(EXPLICIT), explicitly or by default. That requires you to use RELEASE statements in your program to explicitly end connections.
The other values of the option are also useful.
  • DISCONNECT(AUTOMATIC) ends all remote connections during a commit operation, without the need for RELEASE statements in your program.
  • DISCONNECT(CONDITIONAL) ends remote connections during a commit operation except when an open cursor defined as WITH HOLD is associated with the connection.
SQLRULES
Use SQLRULES(Db2), explicitly or by default.

SQLRULES(STD) applies the rules of the SQL standard to your CONNECT statements, so that CONNECT TO x is an error if you are already connected to x. Use STD only if you want that statement to return an error code.

If your program selects LOB data from a remote location, and you bind the plan for the program with SQLRULES(Db2), the format in which you retrieve the LOB data with a cursor is restricted. After you open the cursor to retrieve the LOB data, you must retrieve all of the data using a LOB variable, or retrieve all of the data using a LOB locator variable. If the value of SQLRULES is STD, this restriction does not exist.

If you intend to switch between LOB variables and LOB locators to retrieve data from a cursor, execute the SET SQLRULES=STD statement before you connect to the remote location.

CURRENTDATA
Use CURRENTDATA(NO) to force block fetch for ambiguous cursors.
ENCODING
Use this option to control the encoding scheme that is used for static SQL statements in the plan and to set the initial value of the CURRENT APPLICATION ENCODING SCHEME special register.

For applications that execute remotely and use explicit CONNECT statements, Db2 uses the ENCODING value for the plan. For applications that execute remotely and use implicit CONNECT statements, Db2 uses the ENCODING value for the package that is at the site where a statement executes.

BIND PACKAGE options for DRDA access

The following options of BIND PACKAGE are relevant to binding a package to be run using DRDA access:
location-name
Name the location of the server at which the package runs.

The privileges needed to run the package must be granted to the owner of the package at the server. If you are not the owner, you must also have SYSCTRL authority or the BINDAGENT privilege that is granted locally.

SQLERROR
Use SQLERROR(CONTINUE) if you used SQL(ALL) when precompiling. That creates a package even if the bind process finds SQL errors, such as statements that are valid on the remote server but that the precompiler did not recognize. Otherwise, use SQLERROR(NOPACKAGE), explicitly or by default.
COPY
If you bind with the COPY option to copy a local package to a remote site, Db2 performs authorization checking, reads and updates the catalog, and creates the package at the remote site. Db2 reads the catalog records that are related to the copied package at the local site. Db2 converts values that are returned from the remote site in ISO format if all of the following conditions are true:
  • If the local site is installed with time or date format LOCAL
  • A package is created at a remote site with the COPY option
  • The SQL statement does not specify a different format.
CURRENTDATA
Use CURRENTDATA(NO) to force block fetch for ambiguous cursors.
OPTIONS
When you make a remote copy of a package using BIND PACKAGE with the COPY option, use this option to control the default bind options that Db2 uses. Specify:
  • COMPOSITE to cause Db2 to use any options you specify in the BIND PACKAGE command. For all other options, Db2 uses the options of the copied package. COMPOSITE is the default.
  • COMMAND to cause Db2 to use the options you specify in the BIND PACKAGE command. For all other options, Db2 uses the defaults for the server on which the package is bound. This helps ensure that the server supports the options with which the package is bound.
ENCODING
Use this option to control the encoding scheme that is used for static SQL statements in the package and to set the initial value of the CURRENT APPLICATION ENCODING SCHEME special register.

When you bind the same package locally and remotely, and you specify the ENCODING bind option for the package, the ENCODING bind option for the local package applies to the remote application. The default ENCODING value for a package that is bound at a remote Db2 for z/OS® server is the system default for that server. The system default is specified at installation time in the APPLICATION ENCODING field of panel DSNTIPF, which is the APPENSCH DECP value.

EXPLAIN
If you specify the option EXPLAIN(YES) or EXPLAIN(ONLY), and you do not specify the option SQLERROR(CONTINUE), PLAN_TABLE must exist at the remote location at which the package is bound.