To compile and link a COBOL stored procedure using DB2 LUW:
On Windows platforms:
- Add the program you want to use as a stored procedure to aVisual COBOL project.
- Set the project properties as follows:
- If your program does not contain a
$SET DB2(DB) statement, set this directive on the
SQL Preprocessor page by selecting the
DB2 option for the
Preprocessor Type field.
- If you have 64-bit DB2 LUW installed, but you are building a 32-bit application, you need to update your project properties to specify the fully qualified path and filename of the 32-bit version of the
db2api.lib file, which is a part of your DB2 installation. To do this, open the project properties, expand
Micro Focus > Build Configuration > Link, click
Additional Link Files, and add the path and filename to the
Additional items to be linked field..
- Build the project.1
- At a command prompt or using Windows Explorer, copy the generated
.dll file from its output location (the default is
projectpath\bin\x86\Debug) to the
SQLLIB\FUNCTION subdirectory of your DB2 installation directory.2
On UNIX platforms:
- Compile and link the stored procedure as specified for your platform in the
Building COBOL routines topic of the IBM DB2 LUW documentation.
- Copy the stored procedure object to the
sqllib/function directory of your DB2 Instance.2
Note: 1If your program contains stored procedure CALL statements, you must specify the CALL_RESOLUTION DB2 directive to avoid an SQL0204 error.
Important: 2By default, after calling a stored procedure, DB2 LUW does not unload it until DB2 LUW is stopped. To avoid problems with copying the file, you can do one of the following if you are not in a production environment: