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

COBOL Program Compilation
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
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-15 or 16-19.
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 nmcobol compiler (OSS
environment) or ETK (Windows environment). To produce an object file:
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
nmcobol compiler requires the CONSULT directive to compile the annotated
COBOL source file correctly. The sqlcli.o file contains definitions of the CLI
procedure calls for the translated SQL statements in the annotated COBOL source
file. If you invoke nmcobol with the -Wsqlmx or -Wmxcmp flag, the list of libraries
searched automatically includes sqlcli.o.
Specify the -c option if you do not want nmcobol to link the program. Otherwise,
nmcobol invokes nld to create an executable file.
See Running the COBOL Compiler and Linker on page 16-21.
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:
Running nmcobol with object files as input to link them:
nmcobol -o sqlprog.exe -lzclisrl sqlprog.o