DB2 Version 9.7 for Linux, UNIX, and Windows

Declaration of file reference type host variables in C and C++ embedded SQL applications

The following is the syntax for declaring file reference host variables in C or C++.

Figure 1. Syntax Diagram
Read syntax diagramSkip visual syntax diagram
Syntax for file reference host variables in C or C++

>>-+----------+--+----------+--SQL TYPE IS--+--------+---------->
   +-auto-----+  +-const----+               '-XML AS-'   
   +-extern---+  '-volatile-'                            
   +-static---+                                          
   '-register-'                                          

                    .-,----------------.      
                    V                  |      
>--+-BLOB_FILE---+----+--------------+-+--;--------------------><
   +-CLOB_FILE---+    '-| Variable |-'        
   '-DBCLOB_FILE-'                            

Variable

   .---------------------.                                    
   V                     |                                    
|----+-*-+--+----------+-+--variable-name--+--------------+-----|
     '-&-'  +-const----+                   '-= init-value-'   
            '-volatile-'                                      

Note: SQL TYPE IS, BLOB_FILE, CLOB_FILE, DBCLOB_FILE can be in mixed case.

CLOB file reference example (other LOB file reference type declarations are similar):

Declaration:
   static volatile SQL TYPE IS BLOB_FILE my_file;
Results in the generation of the following structure:
   static volatile struct { 
        sqluint32        name_length; 
        sqluint32        data_length; 
        sqluint32        file_options; 
                 char    name[255]; 
   } my_file;
Note: The structure above is equivalent to the sqlfile structure located in the sql.h header. See Figure 1 to refer to the syntax diagram.