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

COBOL Program Compilation
HP NonStop SQL/MX Programming Manual for C and COBOL544617-003
16-10
Preprocessor Functions
The OSS-hosted SQL/MX COBOL preprocessor resolves the DEFINE =cobdef1 and
the file mapped by DEFINE is processed. Similarly, the file mapped by the DEFINE
=cobdef2 is processed for section section1.
The DEFINE used with a COBOL directive must be MAP DEFINE. The
Windows-hosted COBOL preprocessor does not support Guardian DEFINEs.
COBOL Comments
The preprocessor ignores COBOL comments unless the comment specifies a name for
an SQL statement. You can use a comment to name an SQL statement explicitly. To do
so, precede the statement with a comment using this format:
* SQL statement_name = name [ comment-text ]
EXEC SQL sql_statement ... END-EXEC.
The name is an SQL identifier you are assigning as the name of sql_statement, and
comment-text is an optional comment that does not affect the assignment of the
name. The COBOL comment must use only one line and must immediately precede
the SQL statement.
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.