Preparing a client program that calls a remote stored procedure

If you call a remote stored procedure from an embedded SQL application, you need to do a few extra steps when you prepare the client program. You do not need to do any extra steps when you prepare the stored procedure.

Before you begin

For an ODBC or CLI application, ensure that the Db2 packages and plan that are associated with the ODBC driver are bound to Db2. These packages and plan must be bound before you can run your application.

Procedure

To prepare a client program that calls a remote stored procedure:

  1. Precompile, compile, and link-edit the client program on the local Db2 subsystem.
  2. Bind the resulting DBRM into a package at the local Db2 subsystem by using the BIND PACKAGE command with the option DBPROTOCOL(DRDA).
  3. Bind the same DBRM, the one for the client program, into a package at the remote location by using the BIND PACKAGE command and specifying a location name. If your client program needs to access multiple servers, bind the program at each server.
    For example, suppose that you want a client program to call a stored procedure at location LOCA. You precompile the program to produce DBRM A. Then you can use the following command to bind DBRM A into package collection COLLA at location LOCA:
    BIND PACKAGE (LOCA.COLLA) MEMBER(A)
  4. Bind all packages into a plan on the local Db2 subsystem. Specify the bind option DBPROTOCOL(DRDA).
  5. Bind any stored procedures that run under Db2 ODBC on a remote Db2 database server as a package at the remote site.
    Those procedures do not need to be bound into the Db2 ODBC plan.