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-13
SQL/MX Compiler
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.
When the preprocessor recognizes an EXEC SQL, it finds the corresponding
terminating semicolon (;) for C/C++ programs or the terminating keywords END-
EXEC for COBOL programs.
For each embedded SQL statement, the preprocessor scans the statement to find
host variable references and parses the statement to determine the required CLI
calls. If the statement is valid:
°
If using the default method, the preprocessor writes the embedded module
definitions in the 3GL source file.
°
If you choose to create a module definition file, the preprocessor writes the
output to the module definition file and the 3GL source file.
SQL/MX Compiler
The SQL/MX compiler opens the input program executable (when using Embedded
Module Definitions) or the input module definition file (when using Module Definition
files) and it opens the output module file that will contain the execution plans for the
SQL statements and performs the following functions:
Expands partially qualified SQL object names using the current default settings.
Expands view definitions.
Performs type checking for 3GL and SQL data types.
Checks SQL object references to verify their existence.
Determines an optimized execution plan and access path for each DML statement.
Generates executable code for the execution plans (if the SQL objects in the
statement are present at compile time) and creates a module in the
/usr/tandem/sqlmx/USERMODULES directory (or locally placed module
directory, if specified).
Generates a list of the SQL statements in the program file, including messages.
Returns a completion code indicating the outcome of the compilation.
Host Language Compiler
NonStop SQL/MX supports host applications written in C/C++ and COBOL. For
program preparation, see Section 15, C/C++ Program Compilation, and Section 16,
COBOL Program Compilation.