SQL/MP Programming Manual for COBOL

Host Variables
HP NonStop SQL/MP Programming Manual for COBOL529758-003
2-8
Numeric Data
Numeric Data
Use the PICTURE clause to declare a host variable for numeric data (NUMERIC,
DECIMAL, SMALLINT, LARGEINT, and INTEGER data types):
PICTURE [S] { 9(integer) [ V [ 9(scale) ] ] }
{ V9(scale) }
[ [ USAGE IS ] { DISPLAY } ]
[ { COMPUTATIONAL } ]
[ { COMP } ]
[ { BINARY } ]
If you specify COMPUTATIONAL, COMP, or BINARY, the value is stored as a binary
integer with an implied decimal point. If you omit the USAGE clause, DISPLAY is the
default, and the digits are stored as ASCII characters.
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 of COMP items
is valid for the data. Corresponding SQL columns defined as type NUMERIC,
SMALLINT, INTEGER, LARGEINT, or with COMPUTATIONAL can accept values as
large as the limit determined by the column size in bytes. For example, the COBOL
item described as PIC S9(4) COMP corresponds to an SQL integer column. SQL/MP
allows five-digit values up to 32767, but COBOL allows only four digits (maximum
value 9999).
Note. For systems running J06.09 and later J-series RVUs, H06.20 and later RVUs, or
G06.32 and later G-series RVUs, the SQL integer data types limitations are overridden when
the external DEFINE =_SQL_MAPTO_COBOL_COMP5 is present in the system. In these cases,
the SQL integer columns are mapped to the corresponding COBOL data types with COMP-5
option which rules out these value limitations