The SQL data type specified for the formal parameter in a module
must be equivalent to the data type of the host language variable
declaration for the actual parameter. If the formal parameter and
actual parameter are not declared with equivalent data types, SQL
can give unpredictable results.
However, host languages typically do not support the same set of
data types that SQL supports. To work with a column in a database
defined with a data type not supported in a host language, the
module must declare formal parameters of a data type that the
host language supports. SQL automatically converts between the
data type of the database column and the formal parameter when it
processes the SQL statement in a procedure.
The following table shows the OpenVMS data types that SQL
requires for actual parameters when you declare formal parameters
for each SQL data type.
Table 4 SQL and Corresponding OpenVMS Data Types for Module
Language
Formal
Parameter Data
Type Requires Actual Parameter of OpenVMS Data Type
CHAR (n) Character string (DSC$K_DTYPE_T)
CHAR (n), Character string (DSC$K_DTYPE_T)
qualified by
character set
NCHAR (n) Character string (DSC$K_DTYPE_T)
VARCHAR (n) Varying character string (DSC$K_DTYPE_VT)
VARCHAR (n), Varying character string (DSC$K_DTYPE_VT)
qualified by
character set
NCHAR VARYING Varying character string (DSC$K_DTYPE_VT)
(n)
LONG VARCHAR Varying character string (DSC$K_DTYPE_VT)
TINYINT [(n)] Signed byte integer (DSC$K_DTYPE_B)
SMALLINT [(n)] Signed word integer (DSC$K_DTYPE_W)
INTEGER [(n)] Signed longword integer (DSC$K_DTYPE_L)
BIGINT [(n)] Signed quadword integer (DSC$K_DTYPE_Q)
QUADWORD [(n)] Signed quadword integer (DSC$K_DTYPE_Q)
DECIMAL Packed decimal string (DSC$K_DTYPE_P)
[(n)[,(n)]]
NUMERIC Numeric string, left separate sign (DSC$K_DTYPE_
[(n)[,(n)]] NL)
FLOAT [(n)] Single- or double-precision, floating-point
number, depending on n. For single-precision:
DSC$K_DTYPE_F or DSC$K_DTYPE_FS and for double-
precision: DSC$K_DTYPE_G, DSC$K_DTYPE_D, or
DSC$K_DTYPE_FT.
REAL Single-precision, floating-point number (DSC$K_
DTYPE_F or DSC$K_DTYPE_FS).
DOUBLE Double-precision, floating-point number (DSC$K_
PRECISION DTYPE_G, DSC$K_DTYPE_D, or DSC$K_DTYPE_FT).
(DATE) No equivalent OpenVMS data type; two-longword
array
DATE ANSI No equivalent OpenVMS data type; two-longword
array
DATE VMS Absolute date and time (DSC$K_DTYPE_ADT)
TIME No equivalent OpenVMS data type; two-longword
array
TIMESTAMP No equivalent OpenVMS data type; two-longword
array
INTERVAL (Year- No equivalent OpenVMS data type; two-longword
month) array
INTERVAL (Day- No equivalent OpenVMS data type; two-longword
time) array
LIST OF BYTE Not supported
VARYING