Opaque data types

An opaque data type is a user-defined data structure.

To successfully interpret opaque data types, the database server requires that the DataBlade® module provide opaque data type support routines. You must provide support routines for your opaque data type.

BladeSmith generates boilerplate code for opaque data type support routines. You can write additional code in C or Java™ to implement the functionality your opaque data type requires. If you provide ActiveX value objects as a client-side interface to your opaque data types, you can write the underlying support routines for the opaque data type in C++. See Opaque data type support routines for more information.

Opaque data types typically contain more than one member, so they are similar to row data types, except that the database server can only operate on the individual components with support routines you define in the DataBlade module.

The following diagram illustrates an opaque data type called circle, based on a structure called circle_t, in a column called circle_col.
Figure 1: Sample opaque type

begin figure description - This figure is described in the surrounding text. - end figure description

The table circle_tab consists of the columns circle_id(SERIAL), color(VARCHAR(15)), and circle_col(circle). The opaque data type circle is defined as a C structure, circle_t, which contains a radius member and another structure, point_t. The point_t structure contains x and y members. To the database server, however, the whole circle_t structure is indivisible, unless you provide accessor functions.

Use an opaque type to extend SQL to address fundamentally new data types and allow operations on them. Such data types are typically indivisible or made up of components to which you want to control access.

For example, geographic data and many sorts of rich media data (images, audio, text, and so on) are have been represented by the use of opaque types. Opaque data types often contain smart large objects. Smart large objects are logically stored in a column in a database table but physically stored in a file. For example, an opaque data type for images could have a smart large object member containing the image and other members containing metadata about the image.

Opaque types require more work to create than other data types because you must write all the routines that support them.