C and C++ do not have variables that correspond to the SQL data types for LOBs (large objects). To create host variables that can be used with these data types, use the SQL TYPE IS clause. The SQL precompiler replaces this declaration with a C language structure in the output source member.
>>-+--------+--+----------+--SQL TYPE IS--+-CLOB---+------------> +-auto---+ +-const----+ +-DBCLOB-+ +-extern-+ '-volatile-' '-BLOB---' '-static-' >--(--length--+---+--)------------------------------------------> +-K-+ +-M-+ '-G-' .-,----------------------------------------------------. V | >----variable-name--+-----------------------------------+-+-- ; ->< +- = --{--init-len,"init-data"--}---+ +- = --SQL_CLOB_INIT("init-data")---+ +- = --SQL_DBCLOB_INIT("init-data")-+ '- = --SQL_BLOB_INIT("init-data")---'
The following declaration:
SQL TYPE IS CLOB(128K) var1, var2 = {10, "data2data2"};
The precompiler will generate for C:
_Packed struct var1_t { unsigned long length; char data[131072]; } var1,var2={10,"data2data2"};
The following declaration:
SQL TYPE IS DBCLOB(128K) my_dbclob;
The precompiler will then generate:
_Packed struct my_dbclob_t { unsigned long length; wchar_t data[131072]; } my_dbclob;
The following declaration:
static SQL TYPE IS BLOB(128K) my_blob=SQL_BLOB_INIT("mydata");
Results in the generation of the following structure:
static struct my_blob_t { unsigned long length; char data[131072]; } my_blob=SQL_BLOB_INIT("my_data");
>>-+--------+--+----------+--SQL TYPE IS--+-CLOB_LOCATOR---+----> +-auto---+ +-const----+ +-DBCLOB_LOCATOR-+ +-extern-+ '-volatile-' '-BLOB_LOCATOR---' '-static-' .-,----------------------------------. V | >----variable-name--+-----------------+-+-- ; ----------------->< '- = --init-value-'
The following declaration:
static SQL TYPE IS CLOB_LOCATOR my_locator;
Results in the following generation:
static long int unsigned my_locator;
BLOB and DBCLOB locators have similar syntax.
>>-+--------+--+----------+--SQL TYPE IS--+-CLOB_FILE---+-------> +-auto---+ +-const----+ +-DBCLOB_FILE-+ +-extern-+ '-volatile-' '-BLOB_FILE---' '-static-' .-,----------------------------------. V | >----variable-name--+-----------------+-+-- ; ----------------->< '- = --init-value-'
The following declaration:
static SQL TYPE IS CLOB_FILE my_file;
Results in the generation of the following structure:
static _Packed struct { unsigned long name_length; unsigned long data_length; unsigned long file_options; char name[255]; } my_file;
BLOB and DBCLOB file reference variables have similar syntax.
The precompiler will generate declarations for the following file option constants. You can use these constants to set the file_options variable when you use File Reference host variables.