SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)
Host Variables in C/C++ Programs
HP NonStop SQL/MX Programming Manual for C and COBOL—523627-004
3-4
Date-Time and Interval Host Variables
The length l + 1 is required and must be enclosed in square brackets. The length
l corresponds to the maximum length of the column value. To allow for the null
terminator, add 1 (one) to the length for the declaration of the host variable.
C-initial-value is a valid string literal in C/C++. The initial value should be of
the same type as the C array type translated by the SQL/MX preprocessor.
NCHAR VARYING C-identifier [l + 1] [C-initial-value] [,...]
specifies the data type of a target host variable for a column of this SQL data type:
NCHAR VARYING (l)
C-identifier specifies that the variable can hold a variable-length character (or
code_units) string. The maximum length of the string is specified in the length
field.
The length l + 1 is required and must be enclosed in square brackets. The length
l corresponds to the maximum length of the column value. To allow for the null
terminator, add one (1) to the length for the declaration of the host variable.
NCHAR VARYING is always associated with the system default
NATIONAL_CHARSET. For information on setting NATIONAL_CHARSET, see the
SQL/MX Reference Manual.
C-initial-value is a valid string literal in C/C++. The initial value should be of
the same type as the C array type translated by the SQL/MX preprocessor.
Date-Time and Interval Host Variables
In SQL/MX Release 2.x, you can declare ANSI-99 date-time and interval data types as
host variables. You can use these host variables to retrieve date-time or interval data
directly from date-time or interval columns or to put date-time or interval data directly
into date-time or interval columns.
For SQL/MP DATETIME data types that are not equivalent to DATE, TIME, or
TIMESTAMP, you are still required to declare a character array host variable and use
the CAST function for input to and output from date-time or interval columns, similar to
SQL/MX Release 1.8, which does not support ANSI-99 date-time host variables.
DATE
specifies the data type of a target host variable for a date-time column that
contains a date in the external form yyyy-mm-dd.
TIME [(n)]
specifies the data type of a target host variable for a date-time column that, without
the optional n precision, contains a time in the external form hh:mm:ss. The n
precision is a positive integer that specifies the number of digits in the fractional
seconds. The default for the precision is 0, and the maximum is 6.