Varying-length opaque data type
If the C structure that holds your opaque type can vary in size depending on the data it holds, you must declare the opaque type as a varying-length opaque type.
The opaque type can contain character strings. Each instance of the opaque type can contain a character string with a different size. When you define the internal representation of a varying-length opaque, make sure that only the last member of the C structure is of varying size.
You tell the database server that an opaque type is varying length when you register the opaque type. In the CREATE OPAQUE TYPE statement, you must include the INTERNALLENGTH modifier with the VARIABLE keyword.
The database server stores the value of the INTERNALLENGTH modifier in the length column of the sysxtdtypes system catalog table. For varying-length opaque types, this column holds a value of zero.
Support function for image opaque type | Where to find declaration |
---|---|
Input | Input support function for image opaque type |
Output | Output support function for image opaque type |
Receive | Receive support function for image opaque type |
Send | Send support function for image opaque type |
Import | Import support function for image opaque type |
Export | Export support function for image opaque type |
Importbin | Importbin support function for image opaque type |
Exportbin | Exportbin Support Function for image Opaque Type |
- By default, the maximum size for a varying-length opaque type is two kilobytes.
- You specify a different maximum size for a varying-length opaque
type when you register the opaque type.
In the CREATE OPAQUE TYPE statement, use the MAXLEN modifier. You can specify a maximum length of up to 32 kilobytes. The database server stores the value of the MAXLEN modifier in the maxlen column of the sysxtdtypes system catalog table.
CREATE OPAQUE TYPE var_type
(INTERNALLENGTH=VARIABLE, MAXLEN=4096);
Because the database server uses mi_lvarchar to transfer varying-length data, the passing mechanism for a varying-length opaque type is always by reference. For more information, see Determine the passing mechanism for an opaque type.