SQL/MX Programming Manual for C and COBOL (H06.10+, J06.03+)

COBOL Program Compilation
HP NonStop SQL/MX Programming Manual for C and COBOL544617-003
16-4
Compiling Embedded SQL COBOL Programs With
Embedded Module Definitions
automate the process. For information on using ecobol or nmcobol in this way, see
ecobol or nmcobol Utility: Using One Command for All Compilation Steps on
page 16-32. For more information on using ETK, see ETK online help.
These steps correspond to the steps in Figure 16-1 on page 16-3.
1. Create the COBOL source file that contains embedded SQL statements
(sqlprog.ecob).
2. Preprocess the application’s embedded SQL source file by using the SQL/MX
COBOL preprocessor mxsqlco. See Running the SQL/MX COBOL Preprocessor
on page 16-9.
mxsqlco sqlprog.ecob
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 annotated source file.
3. The preprocessor produces a modified (annotated) COBOL source file
(sqlprog.cbl) that contains the COBOL and SQL call-level interface (CLI)
translations of embedded SQL statements and additional COBOL source
constructs that represent the module definition. The default behavior creates a
single, self-contained application source file with embedded module definitions.
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. If you prefer early
detection of SQL compilation errors, you can SQL compile the application’s object
file at this point. During program development, you might want to use the