Host structure in COBOL applications that use SQL

The following figure shows the syntax for the valid host structure.

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

   .--------------------------------------------------------------------------.   
   V                                .-IS-.                                    |   
>----level-2--var-1--+-+-PICTURE-+--+----+--picture-string--usage-clause--.-+-+-><
                     | '-PIC-----'                                          |     
                     +-floating-point--.------------------------------------+     
                     +-.--varchar-string--.---------------------------------+     
                     +-.--vargraphic-string--.------------------------------+     
                     +-lob--.-----------------------------------------------+     
                     +-datetime--.------------------------------------------+     
                     +-rowid--.---------------------------------------------+     
                     '-binary--.--------------------------------------------'     

floating-point

|--+----------------------------------------+------------------->
   |          .-IS-.                        |   
   | .-USAGE--+----+-.                      |   
   '-+---------------+--+-COMPUTATIONAL-1-+-'   
                        +-COMP-1----------+     
                        +-COMPUTATIONAL-2-+     
                        '-COMP-2----------'     

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

usage-clause

|--+--------------------------------------------+--------------->
   |          .-IS-.                            |   
   | .-USAGE--+----+-.                          |   
   '-+---------------+--+-+-BINARY----------+-+-'   
                        | +-COMPUTATIONAL-4-+ |     
                        | '-COMP-4----------' |     
                        +-+-PACKED-DECIMAL--+-+     
                        | +-COMPUTATIONAL-3-+ |     
                        | +-COMP-3----------+ |     
                        | +-COMPUTATIONAL---+ |     
                        | '-COMP------------' |     
                        +-+-DISPLAY--------+--+     
                        | '-display-clause-'  |     
                        '---DISPLAY-1---------'     

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

display-clause

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

Read syntax diagramSkip visual syntax diagram
varchar-string

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

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

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

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

vargraphic-string

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

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

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

                                                              .-IS-.                
                           .-IS-.                    .-USAGE--+----+-.              
>--49--var-3--+-PICTURE-+--+----+--picture-string-2--+---------------+--DISPLAY-1-->
              '-PIC-----'                                                           

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

Read syntax diagramSkip visual syntax diagram
lob

            .-IS-.                                                           
   .-USAGE--+----+-.                                                         
|--+---------------+--SQL TYPE IS--+-+-CLOB---+--(--lob-length--+---+--)-+--|
                                   | +-DBCLOB-+                 +-K-+    |   
                                   | '-BLOB---'                 '-M-'    |   
                                   +-+-CLOB-LOCATOR---+------------------+   
                                   | +-DBCLOB-LOCATOR-+                  |   
                                   | '-BLOB-LOCATOR---'                  |   
                                   '-+-CLOB-FILE---+---------------------'   
                                     +-DBCLOB-FILE-+                         
                                     '-BLOB-FILE---'                         

datetime

                          .-OF-.                 .-IS-.   
|--variable-name--FORMAT--+----+--+-DATE------+--+----+--------->
                                  +-TIME------+           
                                  '-TIMESTAMP-'           

>--format-options-----------------------------------------------|

rowid

|--SQL TYPE IS ROWID--------------------------------------------|

binary

            .-IS-.                                                        
   .-USAGE--+----+-.                                                      
|--+---------------+--SQL TYPE IS----+-BINARY---------+--(--length--)----|
                                     +-VARBINARY------+                   
                                     '-BINARY VARYING-'                   

Notes:
  1. level-1 indicates a COBOL level between 1 and 47.
  2. level-2 indicates a COBOL level between 2 and 48 where level-2 > level-1.
  3. Graphic host variables, LOB host variables, and floating-point host variables are only supported for ILE COBOL for iSeries™.
  4. For details on declaring numeric, character, graphic, LOB, ROWID, and binary host variables, see the notes under numeric-host variables, character-host variables, graphic-host variables, LOB host variables, ROWID, and binary host variables.
  5. format-options indicates valid datetime options that are supported by the COBOL compiler. See the ILE COBOL Reference manual on the V5R1 Supplemental ManualsLink outside information center Web site for details.