Host structure array in C and C++ applications that use SQL

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

Read syntax diagramSkip visual syntax diagram
>>-+--------+--+----------+--_Packed--struct--+-----+--{-------->
   +-auto---+  +-const----+                   '-tag-'      
   +-extern-+  '-volatile-'                                
   '-static-'                                              

   .----------------------------------------------------------------.      
   |                                               .-,-----.        |      
   V                                               V       |        |      
>----+-+-float----------------------------------+----var-1-+-- ; -+-+--}-->
     | +-double---------------------------------+                 |        
     | +-decimal (--precision--+----------+--)--+                 |        
     | |                       '-,--scale-'     |                 |        
     | |                              .-int-.   |                 |        
     | +-+-+--------+--+-long long-+--+-----+-+-+                 |        
     | | | '-signed-'  +-long------+          | |                 |        
     | | |             '-short-----'          | |                 |        
     | | +-sqlint32---------------------------+ |                 |        
     | | '-sqlint64---------------------------' |                 |        
     | +-varchar-structure----------------------+                 |        
     | +-vargraphic-structure-------------------+                 |        
     | +-lob------------------------------------+                 |        
     | +-SQL-varchar----------------------------+                 |        
     | +-rowid----------------------------------+                 |        
     | '-binary---------------------------------'                 |        
     |                     .-,-----------------------.            |        
     |                     V                         |            |        
     +-+----------+--char----var-2--+--------------+-+-- ; -------+        
     | +-signed---+                 '-[--length--]-'              |        
     | '-unsigned-'                                               |        
     |          .-,-----------------------.                       |        
     |          V                         |                       |        
     '-wchar_t----var-5--+--------------+-+-- ; ------------------'        
                         '-[--length--]-'                                  

   .-,---------------------------------------------------.        
   V                                                     |        
>----variable-name--[--dimension--]--+-----------------+-+-- ; -><
                                     '- = --expression-'          

varchar-structure

                                                   .-int-.               
|--_Packed--struct--+-----+--{--+--------+--short--+-----+--var-3-- ; -->
                    '-tag-'     '-signed-'                               

>--+----------+--char--var-4--[--length--]-- ; --}--------------|
   +-signed---+                                      
   '-unsigned-'                                      

Read syntax diagramSkip visual syntax diagram
vargraphic-structure

                                                   .-int-.               
|--_Packed--struct--+-----+--{--+--------+--short--+-----+--var-6-- ; -->
                    '-tag-'     '-signed-'                               

>--wchar_t--var-7--[--length--]-- ; --}-------------------------|

lob

|--SQL TYPE IS--+-+-CLOB---+--(--length--+---+--)-+-------------|
                | +-DBCLOB-+             +-K-+    |   
                | '-BLOB---'             +-M-+    |   
                |                        '-G-'    |   
                +-+-CLOB_LOCATOR---+--------------+   
                | +-DBCLOB_LOCATOR-+              |   
                | '-BLOB_LOCATOR---'              |   
                '-+-CLOB_FILE---+-----------------'   
                  +-DBCLOB_FILE-+                     
                  '-BLOB_FILE---'                     

SQL-varchar

|--VARCHAR--variable-name--[--length--]-------------------------|

rowid

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

binary

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

Notes:
  1. For details on declaring numeric, character, graphic, LOB, ROWID, and binary host variables, see the notes under numeric-host variables, character-host, graphic-host variables, LOB host variables, ROWID host variables, and binary host variables.
  2. The struct tag can be used to define other data areas, but these cannot be used as host variables.
  3. Dimension must be an integer constant between 1 and 32767.
  4. _Packed must not be used in C++. Instead, specify #pragma pack(1) prior to the declaration and #pragma pack() after the declaration.
  5. If using sqlint32 or sqlint64, the header file sqlsystm.h must be included.