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

Introduction
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
1-12
Processing With Module Definition Files
Section 15, C/C++ Program Compilation
Section 16, COBOL Program Compilation
Section 17, Program and Module Management
Processing With Module Definition Files
This method, which is the only method you can use in SQL/MX Release 1.8, generates
module definition files (.m files). The preprocessor reads a 3GL source file that contains
C/C++ or COBOL and SQL statements and generates two files: an annotated source
file and a module definition file (source-file.m) that contains the SQL source
statements. You compile the source file with the host language compiler, and you
compile the module definition file with the SQL/MX compiler (mxcmp). A module
definition file is not created unless you choose the appropriate preprocessor options.
You must use the -x or -m preprocessor options or the
SQLMX_PREPROCESSOR_VERSION environment variable to create a module definition
file.
For more information, see:
Section 15, C/C++ Program Compilation
Section 16, COBOL Program Compilation
Section 17, Program and Module Management.
General Instructions
1. Use a standard programming editor and create your embedded SQL C/C++ or
COBOL application.
2. Run the SQL/MX C/C++ or COBOL preprocessor to:
a. Parse the EXEC SQL statements and replace them with call-level interface
(CLI) calls.
b. Create embedded module definitions (the default method in SQL/MX Release
2.x) or a module definition file (as in SQL/MX Release 1.8) describing the SQL
statements.
3. Run a standard C/C++ or HP COBOL compiler and linker to create the
application’s executable file.
4. Run the SQL/MX compiler on the executable file to create an execution plan for the
SQL statements and store the plan in a module file. Use mxCompileUserModule
on the application executable when producing embedded module definitions or
mxcmp on the .m file when producing a module definition file.
SQL/MX Host Language Preprocessor
The preprocessor opens the 3GL input source file and the 3GL output source file. By
default, the preprocessor writes the modified source file and the embedded module
definitions in the 3GL source file. If you choose options to create a module definition