SQL Programming Manual for TAL
Host Variables and Parameters
HP NonStop SQL Programming Manual for TAL—527887-001
2-2
Declaring Host Variables
Declaring Host Variables
You declare host variables in a Declare Section in the variable declarations of your
program. You can use multiple Declare Sections in a TAL program, but you cannot nest
the sections. The SQL directives that delimit a Declare Section are BEGIN DECLARE
SECTION and END DECLARE SECTION.
Use TAL naming conventions for your host variables. Host variable names (and
indicator variable names):
•
Can contain from 1 to 31 alphanumeric characters including the circumflex (^) and
the underscore (_)
•
Must begin with a letter, circumflex, or underscore
To prevent naming conflicts, avoid ending your names with an underscore.
Examples of host variable declarations are:
EXEC SQL BEGIN DECLARE SECTION;
! host variables
STRING .buffer[0:length];
INT number[0:9];
STRUCT .s^buffer;
BEGIN
INT buffer_length;
STRING text[0:2046];
END;
EXEC SQL END DECLARE SECTION;
For information about using the INVOKE directive to create host variables, see
Section 3, NonStop SQL Statements and Directives
Using Corresponding SQL and TAL Data Types
Table 2-1 on page 2-3 shows the corresponding NonStop SQL and TAL data types. If
you have an SQL data type shown in the left column and you want to send data to a
variable with that data type or receive data from a variable with that data type, declare
a TAL host variable as shown in the right column.