SQL Programming Manual for TAL
Host Variables and Parameters
HP NonStop SQL Programming Manual for TAL—527887-001
2-6
Using Host Variables
Examples of overriding default data type mapping are:
EXEC SQL BEGIN DECLARE SECTION;
! SQL recognizes empid as a DECIMAL(10) host variable
STRING .empid[0:9]/DECIMAL(10)/;
! SQL recognizes partnum as a SMALLINT UNSIGNED host variable
INT partnum /SMALLINT UNSIGNED/;
! SQL recognizes size as an INTEGER UNSIGNED host variable
INT(32) size /INTEGER UNSIGNED/;
EXEC SQL END DECLARE SECTION;
Using Host Variables
After you declare a host variable, you can use the variable in an SQL statement just as
you would in a TAL statement, except that you must precede the host variable name
with a colon(:). The colon causes the TAL compiler to treat the name as a host
Table 2-2. Default and Override Data Type Mapping
TAL Data Type Default SQL Data Type Override SQL Data Type
STRING CHAR(1) / DECIMAL(1) /
/ DECIMAL(1) UNSIGNED /
STRING[0: n-1] CHAR(n) / DECIMAL(n) / *
/ DECIMAL(n) UNSIGNED / *
INT SMALLINT / SMALLINT UNSIGNED /
INT(32) INTEGER / INTEGER UNSIGNED /
FIXED(0) LARGEINT -
FIXED(s) LARGEINT(s) ** -
REAL REAL -
REAL(64) DOUBLE PRECISION -
STRUCT SQLDA
VARCHAR(n) ***
-
n is a positive integer that represents the length.
s is a positive integer that represents the scale of the number.
* For DECIMAL types, n must be in the range 1 through 18.
** LARGEINT(s) type is used internally to SQL, but it is not an SQL type.
*** The default is the SQLDA unless the structure conforms to type VARCHAR (see Table 2-1
on page 2-3).