SQL Programming Manual for Pascal

Host Variables and Parameters
HP NonStop SQL Programming Manual for Pascal528614-001
2-3
Declaring Host Variables
NonStop SQL Data Conversion
NonStop SQL performs the conversion from SQL data types to Pascal data types and
from Pascal data types to SQL data types as follows:
Table 2-1. Corresponding NonStop SQL and Pascal Data Types
Data SQL Data Type Pascal Data Type
Character CHAR(n)
PIC X(n)
(same as CHAR)
VARCHAR(n)
FSTRING (n)
Numeric NUMERIC (1-4, s) SIGNED
NUMERIC (1-4, s) UNSIGNED
INT16
CARDINAL
NUMERIC (5-9, s) SIGNED
NUMERIC (5-9, s) UNSIGNED (1)
INT32
INT32
NUMERIC (10-18, s) SIGNED INT64
PIC 9 (n-s) V9 (s) COMP
(same as NUMERIC)
DECIMAL(n, s)
PIC 9(n-s)V9(s)
(same as DECIMAL)
(2) DECIMAL(n)
SMALLINT SIGNED
SMALLINT UNSIGNED
INT16
CARDINAL
INTEGER SIGNED
INTEGER UNSIGNED
INT32
none
LARGEINT SIGNED INT64
FLOAT (1 - 22 bits)
REAL (same as FLOAT (1-22) )
REAL
FLOAT (23 - 54 bits)
DOUBLE PRECISION
(same as FLOAT (23-54) )
LONGREAL
DATETIME
TIMESTAMP
DATE
TIME
FSTRING(n)
INTERVAL (3) FSTRING(n) + 1
n is the length, a positive integer.
s is the scale of the number, a positive integer
(1) The Pascal compiler allows you to assign negative numbers to INT32 variables of SQL type NUMERIC
UNSIGNED; however, SQL returns an error when you attempt to store the negative number in the database.
(2) You cannot do arithmetic on DECIMAL columns in Pascal. Conversion routines exist for DECIMAL to
numeric and numeric to DECIMAL; see the Pascal Reference Manual.
(3) For the INTERVAL data type, all host languages generate an extra byte to store a sign. This byte can
contain blanks, a plus, or a minus.