3. Embedded SQL for COBOL : COBOL Data Items and Data Types : Data Types : Numeric Data Category--VMS
 
Share this page                  
Numeric Data Category--VMS
Embedded SQL accepts the following declarations of numeric variables:
level-number data-name PIC [IS] pic-string [USAGE [IS]]
COMP|COMP-3|DISPLAY|PACKED-DECIMAL.
level-number data-name [USAGE [IS]] COMP-1|COMP-2|INDEX.
Note:   
The symbol S may be used on numeric picture strings to indicate the presence of an operational sign.
The picture string (pic-string) of a COMP or COMP-3 data item can contain only the symbols 9, S, and V in addition to the parenthesized length.
To interact with Ingres integer‑valued objects, the picture string of a COMP, COMP‑3 or DISPLAY item should describe a maximum of 10 digit positions with no scaling.
A picture string must not be used for COMP‑1, COMP-2, and INDEX data items. While such a picture string is ignored by the preprocessor, the compiler will not allow it.
Any data items in the numeric category may be used to assign and receive Ingres numeric data in database tables and forms. However, only non‑scaled COMP, COMP‑3, and DISPLAY items of 10 digit positions or less can be used to specify simple numeric objects, such as table field row numbers. Generally, you should use COMP data items with no scaling to interact with Ingres integer‑valued objects, since the internal format of COMP data is compatible with Ingres integer data. Similarly, COMP‑1 and COMP‑2 data items are compatible with Ingres floating-point data.
Although Ingres will effect the necessary conversions between all numeric data types, the use of DISPLAY and COMP‑3 scaled data items could result in the loss of some precision. However, this does not occur if you are using COMP‑3 to store decimals. For more information on type conversion, see Data Type Conversion in this chapter.
Example: Numeric data category usage
01 QUAD-INTVAR  PIC S9(10) USAGE COMP.
01 LONG-INTVAR  PIC S9(9)  USAGE COMP.
01 SHORT-INTVAR PIC S9(4)  USAGE COMP.
01 DISPLAY-VAR  PIC S9(10) USAGE DISPLAY.
01 SING-FLOATVAR USAGE COMP-1.
01 DOUB-FLOATVAR USAGE COMP-2.
01 PACKED-VAR PIC S9(12)V9(4) USAGE COMP-3.