SQL Programming Manual for Pascal
Introduction
HP NonStop SQL Programming Manual for Pascal—528614-001
1-3
Declaring Host Variables
For more information, see Section 3, NonStop SQL Statements and Directives.
Declaring Host Variables
A host variable provides communications between Pascal statements and SQL
statements in a program. A host variable is a Pascal variable with a data type that
corresponds to an SQL data type. You use host variables in SQL statements to receive
data from a database and to insert data into a database.
Host variable names are prefixed with a colon (:) in each SQL statement.
You declare a host variable in a Declare Section, which begins with the BEGIN
DECLARE SECTION directive and ends with the END DECLARE SECTION directive.
In the following example, FILE_NUMBER and MESSAGE are declared as host variables.
{ Variable declarations }
...
EXEC SQL BEGIN DECLARE SECTION;
FILE_NUMBER : INT16; { SQL host variables }
STRING : FSTRING(200);
EXEC SQL END DECLARE SECTION;
For more information on host variables, see Section 2, Host Variables and Parameters.
Calling SQL System Procedures
Use the provided TAL system library procedures to perform various SQL operations
and functions. For example, the SQLCADISPLAY procedure returns error and statistics
information after an SQL statement executes.
A Pascal program can call SQL system procedures in the same way that it might call
other system procedures such as OPEN, READ, WRITEREAD, and CLOSE. The
$SYSTEM.SYSTEM.PEXTDECS file contains source declarations of these procedures
that you can include in your program. The following example shows a call to the
SQLCADISPLAY procedure using all default parameters:
IMPORT BEGIN
?SOURCE $SYSTEM.SYSTEM.PEXTDECS (SQLCADISPLAY)
END;
...
SQLCADISPLAY (XADDR (SQLCA));
For more information, Section 4, NonStop SQL System Procedures.
Using Static SQL Statements
Embedded static SQL statements can replace Pascal statements in a Pascal program.
You can embed static SQL statements in both Pascal data declaration statements and
Pascal executable statements.