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

Introduction
HP NonStop SQL/MX Programming Manual for C and COBOL544617-003
1-13
General Instructions
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
file, the preprocessor also opens the module definition file. The preprocessor reads the
input source file and parses the code:
When the preprocessor recognizes a BEGIN DECLARE SECTION, it parses the
host variables according to the allowed 3GL declaration syntax. You can use only
variables declared in an SQL Declare Section as host variables, providing
communication between 3GL and SQL statements.