An opaque data type is a user-defined data type that can
be used in the same way as the HCL
OneDB™ built-in
data types. The opaque data type allows you to define new data types
for your database applications.
An opaque data type is fully encapsulated; the database server
does not know about the internal format of an opaque data type. Therefore,
the database server cannot make assumptions about how to access a
column having an opaque data type. The database developer defines
a data structure that holds the opaque-type information and support
functions that tell the database server how to access this data structure.
For more information about how to create an opaque data type, see
the description of the CREATE OPAQUE TYPE statement in the HCL OneDB Guide to SQL:
Syntax and in HCL OneDB User-Defined
Routines and Data Types Developer's Guide.
You can access the value of an opaque data type from the application
in one of two ways:
In the external format, as a character string
Transfer of the
external format between the client application and database server
is supported by the database server through the input and output support
functions of the opaque data type.
In the internal format, as a data structure in an external programming
language (such as C)
Transfer of the internal format between
the client application and database server is supported by the database
server through the receive and send support functions of the opaque
data type.
The following list shows the data
types you can use to access an opaque data type.
HCL
OneDB data
type
ESQL/C host variable
External format of an opaque data type
lvarchar host variable
Internal format of an opaque data type
fixed binary host variable
var binary host
variable
This section uses an opaque data type called circle to demonstrate
how lvarchar and fixed
binary host variables access an opaque data type. This data type
includes an x,y coordinate, to represent the center of the circle,
and a radius value. The following figure shows the internal data structures
for the circle data type.
The following figure shows the SQL statements that register the circle data
type and its input, output, send, and receive support functions in
the database.
Suppose the input and output functions of the circle data
type define the following external format that the following figure
shows.
The following figure shows the SQL statements that create and insert
several rows into a table called circle_tab, which has a column
of type circle.