SQL Programming Manual for Pascal

HP NonStop SQL Programming Manual for Pascal528614-001
3-1
3
NonStop SQL Statements and
Directives
This section describes SQL statements and directives that have specific
considerations, data structures, or examples for the Pascal programmatic interface. All
SQL statements, including their syntax, are described in the companion manual,
SQL/MP Reference Manual.
Embedding SQL Statements and Directives
An SQL statement or directive embedded in a Pascal program must begin with the
keywords EXEC SQL and end with a semicolon (;) or other Pascal statement
terminator. The syntax is:
sql-statement-or-directive
is an SQL statement or directive that is allowed in a Pascal program.
An SQL statement ends with the first occurrence of a Pascal statement terminator that
does not appear within an SQL string or comment or a Pascal comment. You terminate
an embedded SQL statement or directive as follows:
In a data declaration, terminate a statement with a semicolon:
EXEC SQL BEGIN DECLARE SECTION;
VAR HostVariableName; { SQL host variable }
EXEC SQL END DECLARE SECTION;
In a procedure, terminate a statement with either a semicolon or Pascal terminator
(END, ELSE, ELSEIF, UNTIL, or OTHERWISE).
IF IN_NUMVARS > 0 THEN
EXEC SQL EXECUTE S1 USING DESCRIPTOR :SDAO
ELSE
EXEC SQL EXECUTE S1;
Coding Statements and Directives
In general, treat SQL statements and directives as if they are Pascal statements,
following the same formatting and line continuation conventions as for Pascal
statements. For example, an embedded SQL statement can be in a Pascal program
anywhere a Pascal statement can be. Here are the guidelines to follow when you
embed SQL statements and directives in a Pascal program:
EXEC SQL sql-statement-or-directive ;