Declare var binary host variables
Element | Purpose | Restrictions | SQL syntax |
---|---|---|---|
opaque type | Name of the opaque data type whose internal format is to be stored in the var binary variable. | Must already be defined in the database | Identifier segment in the HCL OneDB Guide to SQL: Syntax |
variable name | Name of the ESQL/C variable to declare as a var binary variable | Name must conform to language-specific rules for variable names. |
- When you omit opaque type from the var binary declaration,
the database server attempts to identify the appropriate support functions
to use when the application receives the internal data structure from
the opaque-type column in a database.
The advantage of the omission of opaque type is that you can use the var binary host variable to hold data that was selected from several different opaque types (as long as the database server is able to find the appropriate support functions).
The disadvantage of the omission of opaque type is that host variables declared in this way cannot be used as parameters to user defined routines (UDRs).
- When you specify opaque type in the var binary declaration,
the database server knows precisely which support functions to use
when it sends the internal data structure to the database server for
storage in the opaque-type column.
The loss of ambiguity that the opaque type name provides can make data conversion more efficient. However, in this case, the var binary host variable can only hold data from the specified opaque type data type.
You can declare several var binary variables in a single declaration line. However, all variables must have the same opaque type, as Sample var binary host variables shows.