Working with Stored Procedures

Important: Any machine on which a COBOL stored procedure is executed must have a Micro Focus Enterprise Server or Enterprise Server for Stored Procedures product installed and licensed. Contact Customer Care for more information.

Set up the initial environment

Windows

Copy the following DLLs to the function directory under your DB2 instance. This enables DB2 to execute a COBOL stored procedure:

  • cblrtsm.dll
  • cblviom.dll
  • mffh.dll
  • mfhcolib.dll
  • mfsqlsmf.dll

UNIX

See Configuring the Environment for Developing RDBMS Applications on UNIX.

In addition, see the IBM documentation for Building Micro Focus COBOL Routines.

Prepare and execute stored procedures

  1. Code and prepare a stored procedure. See Writing and Preparing Stored Procedures for instructions.
  2. Code and prepare an application that calls the stored procedure. An SQL statement, CALL, in that application must use the same parameter list and linkage convention as the stored procedure that it invokes. See Writing and Preparing Applications to Use Stored Procedures for instructions.
  3. Define your stored procedure to the DB2 LUW Server by issuing a CREATE PROCEDURE command, which will place a row in the appropriate system table(s). See Defining Stored Procedures under DB2 LUW for additional details.
  4. Compile and link your stored procedure. See Compiling and Linking Stored Procedures under DB2 LUW for additional details.
  5. Debug and test your stored procedure. See Debugging Stored Procedures under DB2 LUW for additional details.