SQL Programming Manual for Pascal

Host Variables and Parameters
HP NonStop SQL Programming Manual for Pascal528614-001
2-2
Declaring Host Variables
nest the sections. The SQL directives that delimit a Declare Section are BEGIN
DECLARE SECTION and END DECLARE SECTION.
Use Pascal naming conventions for your host identifiers. Host variable names and
indicator variable names can contain a maximum of 31 alphanumeric characters from
the following categories: letters (A-Z, a-z), digits (0-9), and the underscore (_). The first
character must be a letter, and the name cannot begin with an underscore. To prevent
conflicts with Tandem names, also avoid ending your names with an underscore. Case
is not significant.
Host Variable Declaration Example
This record description declares all columns in the EMPLOYEE table except SALARY
as host variables and includes two record variants, one using LAST_NAME and one
using a name code. The compiler directives BEGIN DECLARE SECTION and END
DECLARE SECTION delimit the Declare Section:
EXEC SQL BEGIN DECLARE SECTION;
TYPE EMPLOYEE = RECORD
EMPNUM : INT16;
FIRST_NAME : FSTRING(15);
( CASE INTEGER OF
1: ( LAST_NAME : FSTRING(20) ) ;
2: ( NAME_CODE_ITEM : FSTRING(2) ) ;
) ;
DEPTNUM : INT16;
JOBCODE : INT16;
END;
VAR EMPLOYEE_REC : EMPLOYEE;
EXEC SQL END DECLARE SECTION;
The following source text declares an item of type DECIMAL. The EMPNUM column
can contain 8 ASCII decimal digits:
EXEC SQL BEGIN DECLARE SECTION;
TYPE EMPLOYEE = RECORD
EMPNUM : DECIMAL(8);
FIRST_NAME : FSTRING(19);
DEPTNUM : INT16;
JOBCODE : INT16;
END;
VAR EMPLOYEE_INFO : EMPLOYEE;
EXEC SQL END DECLARE SECTION;
Corresponding NonStop SQL and Pascal Data Types
Table 2-1 on page 2-3 shows the corresponding SQL and Pascal data types. If you
have a NonStop SQL data type shown in the left column and you want to send data to
that data type or receive data from that data type, declare a Pascal host variable as
shown in the right column.