SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Embedded SQL Statements
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
2-2
Placement of SQL Statements
•
SQL statements can contain SQL comments. SQL comments begin with a double
hyphen (--) and end with the end of the line.
•
Embedded SQL uses the continuation character of the language in which you are
programming.
•
SQL statements can contain host language comments:
°
C comments have the form: /* ... */. The comment is not restricted to one
line.
°
COBOL comments have the form: * ... The asterisk (*) is in the first column
of the source code line in TANDEM free format and in the seventh column of
the source code line for ANSI fixed format. The comment is restricted to one
line.
Placement of SQL Statements
MODULE Directive
The MODULE directive is an embedded SQL statement that specifies the name of an
embedded module for the preprocessor. Place the MODULE directive at the beginning
of a 3GL program and before cursor definitions and executable SQL statements. For
detailed syntax, use considerations, and examples of this statement, see the MODULE
directive in the SQL/MX Reference Manual.
Host Variable Declarations
Code the host variables that are used in SQL statements in the SQL Declare Section.
In embedded SQL programs, the SQL Declare Section is equivalent to a variable
declaration. You can place an SQL Declare Section wherever it is legal to place
declarations in a C, C++, or COBOL program. An embedded program can contain
more than one SQL Declare Section.
You can place an SQL Declare Section relative to executable SQL statements in your
embedded program. For a list of executable SQL statements, see Table 2-4 on
page 2-8.
To code an SQL Declare Section:
•
Use BEGIN DECLARE SECTION to mark the beginning of the Declare Section.
•
Code the host variables used in SQL statements within the Declare Section.
Note. Many of the examples in this manual use the NonStop SQL/MX Release 2.x sample
database, which uses SQL/MX format tables. To install the sample database, you must have a
license to use SQL/MX DDL statements. To acquire the license, purchase product T0394.
Without this product, you cannot install the sample database; an error message informs you
that the system is not licensed.