3. Embedded SQL for COBOL : COBOL Data Items and Data Types : Data Types : Numeric Data Category—Windows and UNIX
 
Share this page                  
Numeric Data Category—Windows and UNIX
Embedded SQL/COBOL accepts the following declarations of numeric variables:
level-number data-name PIC [IS] pic-string [USAGE [IS]COMP|COMP-3
              |COMP-5|DISPLAY.
level-number data-name [USAGE [IS]] INDEX.
Syntax Notes:
Use the symbol S on numeric picture strings to indicate the presence of an operational sign.
The picture string (pic-string) of a COMP, COMP-3, or COMP-5 data item can contain only the symbols 9, S, and V in addition to the parenthesized length.
To interact with Ingres integervalued objects, the picture string of a COMP, COMP3, COMP5, or DISPLAY item must describe a maximum of 10 digit positions with no scaling.
Do not use a picture string for INDEX data items. While the preprocessor ignores such a picture string, the compiler does not allow it.
You can use any data items in the numeric category to assign and receive Ingres numeric data in database tables and forms. However, only use nonscaled COMP, COMP3, COMP5, and DISPLAY items of 10 digit positions or less to specify simple numeric objects, such as table field row numbers. Generally, try to use COMP data items with no scaling to interact with Ingres integervalued objects, since the internal format of COMP data is compatible with Ingres integer data. Ingres effects the necessary conversions between all numeric data types, so the use of DISPLAY and COMP3 scaled data items is allowed. For more information on type conversion, see Data Type Conversion (see page 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 PACKED-VAR   PIC  S9(12)V9(4) USAGE COMP-3.
Numeric Data Items with Usage COMP‑5—UNIX
Ingres supports data items declared with USAGE COMP5. When you specify this clause, the data item is stored in the same machine storage format as the native host processor rather than in the bytewise Micro Focus storage format. Of course, sometimes the two storage formats are identical. Since the Ingres runtime system that is linked into your COBOL runtime support module (RTS) is written in C, it is important that Ingres interact with native data types rather than Micro Focus data types. Consequently, many of your normal USAGE COMP data items are transferred (using COBOL MOVE statements) into internally declared Ingres USAGE COMP5 data items. Data items declared with this USAGE cause a compiler information message (209 I) to occur.
Dynamic SQL requires that your program point directly at result data items. In that case, you may be required to use USAGE COMP5 data items, rather than having the option to use COMP or COMP-5. For details on dynamic SQL, see Dynamic Programming for COBOL (see page Dynamic Programming for COBOL) in this chapter.