SQL Programming Manual for TAL
Introduction
HP NonStop SQL Programming Manual for TAL—527887-001
1-3
Declaring Host Variables
Table 1-2 shows the NonStop SQL directives you can embed in a TAL program.
For more information, see Section 3, NonStop SQL Statements and Directives
Declaring Host Variables
A host variable provides communication between TAL statements and SQL statements
in a program. A host variable is a TAL 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. When you use a host variable with an
SQL statement, you precede the host variable name with a colon (:).
You declare host variables in a Declare Section with the TAL variable declarations. A
Declare Section begins with the BEGIN DECLARE SECTION directive and ends with
the END DECLARE SECTION directive. In this example, FILE^NUMBER and
MESSAGE are host variables.
! TAL declarations
...
EXEC SQL BEGIN DECLARE SECTION;
INT file^number; ! SQL host variables
STRING .message[80] ;
EXEC SQL END DECLARE SECTION;
...
! More TAL declarations
...
For more information, 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 TAL program can call SQL system procedures in the same manner that it might call
other system procedures such as OPEN, READ, WRITEREAD, and CLOSE. The
$SYSTEM.SYSTEM.EXTDECS file contains source declarations of these procedures
Table 1-2. NonStop SQL Directives
Type Directive
Data Declaration BEGIN DECLARE SECTION, END DECLARE SECTION, INCLUDE
SQLCA, INCLUDE SQLDA, INCLUDE SQLSA
Data Control CONTROL EXECUTOR, CONTROL QUERY, CONTROL TABLE
Error Checking WHENEVER