SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
COBOL Program Compilation
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
16-10
Preprocessor Functions
For example, this comment names the SQL statement (INSERT) and provides 
comment text (“insert ten rows”):
* SQL statement_name= INSERT insert ten rows
 EXEC SQL INSERT INTO ... END-EXEC.
If you do not specify a name for an SQL statement, the preprocessor assigns the 
statement a name of the form SQLMX_DEFAULT_STATEMENT_n, where n is an integer 
incremented by the preprocessor.
Host Variable Declarations
The preprocessor checks each host variable declaration (that is, a variable declared 
between BEGIN DECLARE SECTION and END DECLARE SECTION) to ensure that 
the variable uses a valid data type. For valid host-variable data types, see Table 4-1 on 
page 4-5 and Table 4-2 on page 4-7.
The preprocessor returns an error for embedded SQL statements that are not valid 
within a host-variable declaration section.
SQLSTATE must be declared within a Declare Section. See Declaring SQLSTATE on 
page 13-1.
Executable SQL Statements
The preprocessor performs these functions:
•
Scans the statement for host variables (indicated by a colon) and ensures that 
each host variable is declared within the current scope of the program.
•
Converts the SQL statement to a COBOL comment in the COBOL annotated 
source file.
•
Writes data structure initialization statements needed for arguments to the CLI 
procedure calls and writes the appropriate CLI procedure call or calls for the SQL 
statement immediately after the commented statement in the COBOL annotated 
source file. At run time, the calls invoke the SQL/MX executor to execute the 
procedure for the SQL statement within the module.
•
Writes the executable SQL statement to a separate module definition file if you use 
the -x or -m preprocessor option or set the 
SQLMX_PREPROCESSOR_VERSION=800 environment variable.
Use the preprocessor to embed SQL anywhere in the COBOL source file. However, 
the preprocessor determines in which part of the source file the embedded SQL is 
located and issues warnings if an embedded SQL statement is not placed correctly. 
See Placement of SQL Statements on page 2-2.
At the end of processing the embedded SQL COBOL source file, the preprocessor 
checks the status of static cursors:
•
Cursors accessed and not opened return an error message.










