Numeric host variables in COBOL applications that use SQL

The following figure shows the syntax for valid integer host variable declarations.

BIGINT and INTEGER and SMALLINT

Read syntax diagramSkip visual syntax diagram
>>-+-01------+--variable-name--+-PICTURE-+---------------------->
   +-77------+                 '-PIC-----'   
   '-level-1-'                               

                                    .-IS-.     
   .-IS-.                  .-USAGE--+----+-.   
>--+----+--picture-string--+---------------+-------------------->

>--+-BINARY----------+--+---------------------------------+----->
   +-COMPUTATIONAL-4-+  |        .-IS-.                   |   
   '-COMP-4----------'  '-VALUE--+----+--numeric-constant-'   

>--.-----------------------------------------------------------><

Notes:
  1. BINARY, COMPUTATIONAL-4, and COMP-4 are equivalent. A portable application should code BINARY, because COMPUTATIONAL-4 and COMP-4 are IBM® extensions that are not supported in International Organization for Standardization (ISO)/ANSI COBOL. The picture-string associated with these types must have the form S9(i)V9(d) (or S9...9V9...9, with i and d instances of 9). i + d must be less than or equal to 18.
  2. level-1 indicates a COBOL level between 2 and 48.

The following figure shows the syntax for valid decimal host variable declarations.

DECIMAL

Read syntax diagramSkip visual syntax diagram
>>-+-01------+--variable-name--+-PICTURE-+---------------------->
   +-77------+                 '-PIC-----'   
   '-level-1-'                               

                                    .-IS-.     
   .-IS-.                  .-USAGE--+----+-.   
>--+----+--picture-string--+---------------+-------------------->

>--+-PACKED-DECIMAL--+--+---------------------------------+----->
   +-COMPUTATIONAL-3-+  |        .-IS-.                   |   
   +-COMP-3----------+  '-VALUE--+----+--numeric-constant-'   
   +-COMPUTATIONAL---+                                        
   '-COMP------------'                                        

>-- . ---------------------------------------------------------><

Notes:
  1. PACKED-DECIMAL, COMPUTATIONAL-3, and COMP-3 are equivalent. A portable application should code PACKED-DECIMAL, because COMPUTATIONAL-3 and COMP-3 are IBM extensions that are not supported in ISO/ANS COBOL. The picture-string associated with these types must have the form S9(i)V9(d) (or S9...9V9...9, with i and d instances of 9). i + d must be less than or equal to 63.
  2. COMPUTATIONAL and COMP are equivalent. The picture strings associated with these and the data types they represent are product specific. Therefore, COMP and COMPUTATIONAL should not be used in a portable application. In the COBOL for iSeries™ program, the picture-string associated with these types must have the form S9(i)V9(d) (or S9...9V9...9, with i and d instances of 9). i + d must be less than or equal to 63.
  3. level-1 indicates a COBOL level between 2 and 48.

The following figure shows the syntax for valid numeric host variable declarations.

Numeric

Read syntax diagramSkip visual syntax diagram
>>-+-01------+--variable-name--+-PICTURE-+---------------------->
   +-77------+                 '-PIC-----'   
   '-level-1-'                               

   .-IS-.                   
>--+----+--picture-string--------------------------------------->

>--+---------------------------------------+-------------------->
   |          .-IS-.                       |   
   | .-USAGE--+----+-.                     |   
   '-+---------------+--+-DISPLAY--------+-'   
                        '-display clause-'     

>--+---------------------------------+-- . --------------------><
   |        .-IS-.                   |        
   '-VALUE--+----+--numeric-constant-'        

display clause

   .-DISPLAY-.        .-IS-.                    .-CHARACTER-.   
|--+---------+--SIGN--+----+--LEADING SEPARATE--+-----------+---|

Notes:
  1. The picture-string associated with SIGN LEADING SEPARATE and DISPLAY must have the form S9(i)V9(d) (or S9...9V9...9, with i and d instances of 9). i + d must be less than or equal to 18.
  2. level-1 indicates a COBOL level between 2 and 48.