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-2
Compiling SQL/MX Applications and Modules
Compiling SQL/MX Applications and Modules
NonStop SQL/MX Release 2.x provides two methods of compiling embedded SQL
COBOL programs and creating modules. Both methods create an identical module file.
The first method described, using embedded module definitions, is the default and
preferred method.
The SQL/MX preprocessor reads a source file that contains COBOL and embedded
SQL statements and generates:
The preprocessor (mxsqlco) appends an embedded module definition, which includes
a ?COLUMNS directive by default, at the end of an annotated source file. Only one
?COLUMNS directive is allowed in a source file. Otherwise, the COBOL compiler
returns an error. If your source file contains a ?COLUMNS directive, you must either:
Remove the ?COLUMNS directive from the source file before generating an
embedded module definition.
Keep the ?COLUMNS directive in the source file and generate a module definition
file instead of an embedded module definition.
Method 1: Embedded
module definition
One file: a single, self-contained annotated source file
that contains source statements with SQL statements
converted to comments and embedded module
definitions. You compile this file (source-file.ecob
in embedded SQL/MX COBOL programs) with the
COBOL compiler (nmcobol) and the SQL/MX compiler
(mxCompileUserModule). This is the default and
preferred method.
Method 2: Annotated
source file and module
definition file
Two files: an annotated source file and a module
definition file (source-file.m) that contains SQL
source statements. You compile the source file with the
COBOL compiler, and you compile the module
definition file with the SQL/MX compiler (mxcmp). A
module definition file is not created unless you use the
-x or -m preprocessor options or set the
SQLMX_PREPROCESSOR_VERSION=800 environment
variable to create a module definition file. For more
information, see Influencing Module Management
Behavior on page 17-7.