The complete set of methods used within COBOL to manipulate copybooks is not available with database precompilers and COBSQL itself cannot handle included copybooks. These problems can be overcome by using the Micro Focus Copybook Preprocessor (CP).
CP is a preprocessor that provides other preprocessors, such as COBSQL, with a mechanism for handling copybooks. CP follows the same rules as the COBOL Compiler for handling copybooks, so any copybook-related Compiler directives are automatically picked up and copybooks are searched for using the COBCPY environment variable. CP also expands the following statements:
EXEC SQL INCLUDE ... END-EXEC
Oracle uses .pco and .cob extensions, Sybase uses .pco and .cbl extensions and Informix uses .eco, .cob and .mf2 extensions.
For CP to resolve copybooks and include statements correctly, use the following COBOL Compiler directives for Sybase and Oracle:
copyext (pco,cbl,cpy,cob) osext(pco)
copyext (eco,mf2,cbl,cpy,cob) osext(eco)
COBSQL can call CP to expand copybooks before the database precompiler is invoked. This means that all the copy-related commands are already resolved so that it appears to the database precompiler that a single source file is being used.
The other advantage of using CP is that it makes copybooks visible when debugging.
When CP sees an INCLUDE SQLCA statement, it does the following:
You can specify the CP preprocessor's SY directive to prevent CP expanding the SQLCA include file, for example:
preprocess(cobsql) preprocess(cp) sy endp
You should always use CP's SY directive when processing Sybase code because Sybase expects to expand the SQLCA itself.
If the MODE=ANSI option is specified to the Oracle precompiler, Pro*COBOL, then you should additionally use CP's SY directive to ensure that the SQLCA gets populated correctly.
As Oracle can produce code with either COMP or COMP-5 variables, it has two sets of copybooks. The standard sqlca.cob, oraca.cob and sqlda.cob all have COMP data items. The sqlca5.cob, oraca5.cob and sqlda5.cob files have COMP-5 data items. If you are using the comp5=yes Oracle directive, you must set the COBSQL directive MAKESYN to convert the COMP items in the SQLCA to COMP-5.
If CP produces errors when attempting to locate copybooks, check to make sure that the OSEXT and COPYEXT Compiler directives are set correctly. COPYEXT should be set first and should include as its first entry the extension used for source files (.pco or .eco, for example).
If these are set correctly, ensure that the copybook is either in the current directory or in a directory on the COBCPY path.
When using CP in conjunction with COBSQL, SQL errors inside included copybooks will be reported correctly. Without CP, the line counts will be wrong, and the error will either go unreported or will appear on the wrong line.