Creating COBOL external stored procedures in Db2
Use the PGMNAME(MIXED)
option to create the COBOL stored procedures
and link them with the -shared
option to produce a shared object. You can use the
cob2_db2
command to do both the compilation and linking at the same
time or separately. To link a COBOL program, you should always use cob2_db2
instead of using gcc
or ld
directly.
The PROGRAM-ID paragraph in the COBOL source for the stored procedure must match the name, including casing, of the shared object you create in the file system when you compile and link the program.
Specify the absolute path to the shared object in the EXTERNAL NAME clause of the
CREATE PROCEDURE statement. If your stored procedure shared object is at this path:
/home/jdoe/db2sp/storedProc1
, you should specify this path in the EXTERNAL
NAME clause.