Declare fixed binary host variables

Use the fixed binary data type to declare host variables that access the internal format of a fixed-length opaque data type.

To declare a fixed binary host variable, use the following syntax.

1 (1)  fixed binary?  ’ opaque typestructure name + , variable name  ;
Notes:
  • 1 HCL OneDB™ extension
Element Purpose Restrictions SQL Syntax
opaque type Name of the fixed-length opaque data type whose internal format is to be stored in the fixed binary variable Must already be defined in the database. Identifier segment in the HCL OneDB Guide to SQL: Syntax
structure name Name of the C data structure that represents the internal format of the opaque data type Must be defined in a header (.h) file that the source file includes. Must also match the data structure that the database server uses to represent the internal format of the opaque type. Name must conform to language-specific rules for structure names.
variable name Name of the ESQL/C variable to declare as a fixed binary variable Name must conform to language-specific rules for variable names.
Important: A fixed binary host variable is only valid for a column of a fixed-length opaque data type. If the opaque data type is of varying length, use a var binary host variable. If you do not know the internal data structure of a fixed-length opaque data type, you must also use a var binary host variable to access it.

To use a fixed binary host variable, you must reference a C data structure that maps the internal data structure of the opaque data type. You specify this C data structure as the structure name in the fixed binary declaration.

It is suggested that you create a C header file (.h file) for the C data structure that defines a fixed-length opaque data type. You can then include this header file in each source file that uses fixed binary host variables to access the opaque data type.

For example, the following code fragment declares a fixed binary host variable called my_circle for the circle opaque data type:
#include <circle.h>   /* contains definition of circle_t */

EXEC SQL BEGIN DECLARE SECTION;
   fixed binary 'circle' circle_t my_circle;
EXEC SQL END DECLARE SECTION;

In this example, the circle.h header file contains the declaration for the circle_t structure (see Internal data structures for the circle opaque data type), which is the internal data structure for the circle opaque type. The declaration for the my_circle host variable specifies both the name of the opaque data type, circle, and the name of its internal data structure, circle_t.