C and C++ do not have variables that correspond to the SQL binary data types. 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--BINARY--(length)------> +-auto---+ +-const----+ +-extern-+ '-volatile-' '-static-' .-,---------------------------------. V | >----variable-name--+----------------+-+-- ; ------------------>< '- = --init-data-'
>>-+--------+--+----------+--SQL TYPE IS--+-VARBINARY------+----> +-auto---+ +-const----+ '-BINARY VARYING-' +-extern-+ '-volatile-' '-static-' >--(length)-----------------------------------------------------> .-,-------------------------------------------------------. V | >----variable-name--+--------------------------------------+-+--> +- = --{--init-len,"init-data"--}------+ '- = --SQL_VARBINARY_INIT("init-data")-' >-- ; ---------------------------------------------------------><
The following declaration:
SQL TYPE IS BINARY(4) myBinField;
Results in the generation of the following code:
unsigned char myBinField[4];
The following declaration:
SQL TYPE IS VARBINARY(12) myVarBinField;
Results in the generation of the following structure:
_Packed struct myVarBinField_t { short length; char data[12]; } myVarBinField;