SQL/MX Programming Manual for C and COBOL (H06.10+, J06.03+)
COBOL Program Compilation
HP NonStop SQL/MX Programming Manual for C and COBOL—544617-003
16-7
Compiling Embedded SQL COBOL Programs With
Module Definition Files
1. Create the COBOL source files that contain embedded SQL statements
(sqlprog.ecob).
2. Preprocess the application’s embedded SQL source files by using the SQL/MX
COBOL preprocessor mxsqlco. See Running the SQL/MX COBOL Preprocessor
on page 16-9.
mxsqlco sqlprog.ecob -c sqlprog.cbl -m sqlprog.m
In this step, set optional module specification strings and moduleCatalog and
moduleSchema default settings by using the -g option. See page 16-16 or 16-21.
Although you do not set mxcmp defaults here, if the input source file contains
mxcmp default settings, such as EXEC SQL DECLARE/SET/CONTROL QUERY
DEFAULT statements, they are preprocessed into corresponding module language
statements in the output module definition of the module definition file. The
preprocessor options (-x or -m) and the SQLMX_PREPROCESSOR_VERSION=800
environment variable indicate to the preprocessor that you are compiling your
program with module definition files. For more information on setting the
preprocessor options, see Module Management Behavior on page 17-7.
3. The preprocessor produces two files: (1) a modified (annotated) COBOL source
file (sqlprog.cbl) that contains the COBOL and SQL CLI translations of
embedded SQL statements and (2) a module definition file (sqlprog.m).
4. Compile the annotated COBOL source file by using the ecobol or nmcobol
compiler (OSS environment) or ETK (Windows environment). To produce an object
file:
ecobol -Wcobol="consult /usr/tandem/sqlmx/lib/esqlcli.o" \
-o sqlprog.o -c sqlprog.cbl
nmcobol -Wcobol="consult /usr/tandem/sqlmx/lib/sqlcli.o" \
-o sqlprog.o -c sqlprog.cbl
If you do not specify the -Wsqlmx or -Wmxcmp flag in the command line, the
ecobol or nmcobol compiler requires the CONSULT directive to compile the
annotated COBOL source file correctly. The esqlcli.o or sqlcli.o file
contains definitions of the CLI procedure calls for the translated SQL statements in
the annotated COBOL source file. If you invoke ecobol or nmcobol with the
-Wsqlmx or -Wmxcmp flag, the list of libraries searched automatically includes
esqlcli.o or sqlcli.o.
Specify the -c option if you do not want ecobol or nmcobol to link the program.
Otherwise, ecobol or nmcobol invokes eld or nld to create an executable file.
See Running the COBOL Compiler and Linker on page 16-23.
5. The COBOL compiler produces the object file, sqlprog.o.
6. Link application object files with object libraries to create an executable file by
either:










