SQL/MX Programming Manual for C and COBOL (G06.24+, H06.03+)

Host Variables in COBOL Programs
HP NonStop SQL/MX Programming Manual for C and COBOL523627-004
4-13
Date-Time and Interval Data
COMP and DISPLAY Data
If you specify COMP or BINARY, the value is stored as a binary integer with an implied
decimal point. If you omit COMP or BINARY, DISPLAY is the default, and the digits are
stored as ASCII characters.
Sign, Number of Digits, and Scale
The S specifies a signed variable. If you omit S, the variable is unsigned.
The 9(integer) specifies integer number of digits; integer must be positive. The
V designates a decimal position.
The 9(scale) designates the number of positions to the right of the decimal. The value
of scale must be a positive integer. If you do not specify scale, the value 0 is used.
Instead of integer or scale, you can specify multiple 9s, with each 9 representing
one digit. You can also specify multiple 9s, integers, or scales, as allowed in COBOL.
For example, PIC 9V9 has a scale of 1. PIC 999(4)V999 is equivalent to PIC 9(6)V9(3)
and has a scale of 3.
The values of integer and scale determine the size of the column. The sum of
these values cannot exceed 18. There is no default numeric column definition. You
must specify either 9(integer) or V9(scale).
You must ensure that the value limit imposed by the PICTURE clause is valid for the
data. Corresponding SQL columns defined as type DECIMAL, NUMERIC, PICTURE
9’s COMP, SMALLINT, LARGEINT, and INTEGER data types can accept values as
large as the limit determined by the column size in bytes.
Date-Time and Interval Data
Use the following for date-time and interval data types:
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 Representation
You can insert or retrieve date-time values in any of three formats, independently of
the SQL column definition. For example, you can specify formats such as 09/15/1993,
1993-09-15, or 15.09.1993. You control the display format by inserting the value in the
DATE Represents a date.
TIME Represents a time.
TIMESTAMP Represents a timestamp.
INTERVAL Represents a duration of time as a year-month or day-time interval.