Character host variables in COBOL applications that use SQL

There are two valid forms of character host variables.

Fixed-length character strings

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

   .-IS-.                                                   
>--+----+--picture-string--+----------------------------+------->
                           |          .-IS-.            |   
                           | .-USAGE--+----+-.          |   
                           '-+---------------+--DISPLAY-'   

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

Notes:
  1. The picture string associated with these forms must be X(m) (or XXX...X, with m instance of X) with 1 ≤ m ≤ 32 766.
  2. level-1 indicates a COBOL level between 2 and 48.

Varying-length character strings

Read syntax diagramSkip visual syntax diagram
>>-+-01------+--variable-name-- . ------------------------------>
   '-level-1-'                       

                           .-IS-.                     
>--49--var-1--+-PICTURE-+--+----+--picture-string-1------------->
              '-PIC-----'                             

            .-IS-.                          
   .-USAGE--+----+-.                        
>--+---------------+--+-BINARY----------+----------------------->
                      +-COMPUTATIONAL-4-+   
                      '-COMP-4----------'   

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

                           .-IS-.                     
>--49--var-2--+-PICTURE-+--+----+--picture-string-2------------->
              '-PIC-----'                             

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

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

Notes:
  1. The picture-string-1 associated with these forms must be S9(m) or S9...9 with m instances of 9. m must be from 1 to 4.

    Note that the database manager will use the full size of the S9(m) variable even though COBOL on the iSeries™ only recognizes values up to the specified precision. This can cause data truncation errors when COBOL statements are being run and may effectively limit the maximum length of variable-length character strings to the specified precision.

  2. The picture-string-2 associated with these forms must be either X(m), or XX...X, with m instances of X, and with 1 ≤ m ≤ 32 740.
  3. var-1 and var-2 cannot be used as host variables.
  4. level-1 indicates a COBOL level between 2 and 48.