SQL/MP Programming Manual for COBOL

SQL/MP Statements and Directives
HP NonStop SQL/MP Programming Manual for COBOL529758-003
3-2
Placing SQL Statements and Directives
Precede an SQL statement with a COBOL section or paragraph name.
If you place COBOL and SQL statements on the same line, these restrictions
apply:
The COBOL statement cannot be a COPY or REPLACE statement.
A COBOL statement must follow the embedded SQL statement terminator. It
cannot precede an embedded SQL statement on a line.
Use either SQL or COBOL comments within SQL statements and directives. An
SQL comment begins with a double hyphen (--) and ends with the end of the line.
A COBOL comment has an asterisk (*) in the indicator field (column 1 in HP format
or column 7 in ANSI format) and ends with the end of the line.
If you specify a delimiter on an executable SQL statement in the Procedure
Division, the delimiter affects program execution. A COBOL statement is generated
from the embedded SQL statement, and the delimiter is appended to the
generated statement. Consequently, you can use SQL statements in conditional
statements, such as IF and ELSE.
If you specify a delimiter on an SQL statement in the Data Division or a
non-executable statement in the Procedure Division, the delimiter appears only in a
comment line. The HP COBOL compiler copies both the embedded SQL directive
and the delimiter to comment lines. The delimiter is not appended to any resulting
data declaration.
Do not code an SQL statement or directive on a COBOL debugging line.
Placing SQL Statements and Directives
Place SQL statements, SQL directives, and COBOL compiler directives in a COBOL
source file as described in this subsection.
SQL Compiler Directive
You must specify the SQL compiler directive before the first Identification Division in
your program. The SQL directive indicates to the HP COBOL compiler that the
compilation unit contains SQL statements or directives.
You can specify the SQL directive either in your source code file or as a compiler
option in the implicit TACL RUN command for the HP COBOL compiler. This example
shows the SQL directive in a source code file:
?SQL
This example shows the SQL directive as a compiler option:
COBOL85 /IN COBSRC,OUT $S.#COBLIST,NOWAIT/ COBOBJ; SQL
After the SQL directive, place other SQL statements and directives in a COBOL source
file as described in this subsection.