Problem:
How do you specify location of copybooks and include files using Oracle ?
Resolution:
There are two ways to resolve the location and expansion of copybooks. One is through the use of Oracle's Pro*COBOL INCLUDE option and the other is by using the CP pre-processor along with setting COBOL's COBCPY environment variable. The assumption being made is that the copybooks contain either embedded SQL statements or the declaration of host variables used in embedded SQL statements and the copybooks are not located in the source/default directory.
(1)
Using Oracle's Pro*COBOL INCLUDE option.
This solution only works if the copybooks are included with the EXEC SQL INCLUDE statement.
(and extension is cob). This is the easiest solution since Pro*COBOL automatically expands files included through the EXEC SQL INCLUDE statement if they can be located. In order to specify the location, use Pro*COBOL INCLUDE option for each unique file location. This option specifies a single location/directory path. You can specify multiple paths by using multiple INCLUDE statements. The syntax is
INCLUDE=<path1> INCLUDE=<path2>
The precompiler will incorporate the copybook into the generated precompiled code. Pro*COBOL looks for the file in the current directory first, then in the directories specified by the INCLUDE parameters in the order specified. T he INCLUDE parameter can be placed in the Oracle configuration file pcbcfg.cfg or specified inline with the compiler directives. In the later case it must appear after the END-C directive and before the ENDP directive, example:
P(COBSQL) COBSQLTYPE=ORACLE VERBOSE END-C INCLUDE=<path1> INCLUDE=<path2> ENDP
(2)
Using P(CP) and COBCPY
If the copybooks are included with the EXEC SQL INCLUDE statement or the COPY statement, you can use COBCPY to identify the location of the copybooks and P(CP) to expand these files before the Oracle precompiler is invoked. In addition to the current directory the COBCPY environment variable identifies the directory locations to search for copybooks specified in the COBOL source. The search order is the current directory and then along the COBCPY path in the order specified. The syntax for specifying the COBCPY environment variable is
SET COBCPY=<path1>;<path2>;%COBCPY%
It can be set through the Net Express IDE by selecting
Project> Properties > IDE Environment > Environment variables
See Net Express on-line help for more information on using COBCPY environment variable.
The CP pre-processor expands the copybooks located on the COBCPY path and in the current directory. Copyfiles that include embedded sql statements or the declaration of host variables must be expanded and precompiled. The P(CP) directive should be placed after COBSQL END-C directive and before the ENDP directive, example:
P(COBSQL) COBSQLTYPE=ORACLE VERBOSE END-C P(CP) ENDP