informix
INFORMIX-ESQL/C Programmer's Manual
Working with Opaque Data Types of the Universal Data Option

The SQL Opaque Data Type

An opaque data type is a user-defined data type that can be used in the same way as the Informix 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 on how to create an opaque data type, see the description of the CREATE OPAQUE TYPE statement in the Informix Guide to SQL: Syntax and in Extending Informix Dynamic Server.

You can access the value of an opaque data type from an ESQL/C application in one of two ways:

The following table shows the ESQL/C data types you can use to access an opaque data type.

Universal Server 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 chapter uses an opaque data type called circle to demonstrate how ESQL/C 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. Figure 10-1 shows the internal data structures for the circle data type.


Figure 10-1
Internal Data Structures for the circle Opaque Data Type

Figure 10-2 shows the SQL statements that register the circle data type and its input, output, send, and receive support functions in the database.


Figure 10-2
Registering the circle Opaque Data Type

Suppose the input and output functions of the circle data type define the following external format that Figure 10-3 shows.

Figure 10-3
External Format of the circle Opaque Data Type

Figure 10-4 shows the SQL statements that create and insert several rows into a table called circle_tab, which has a column of type circle.


Figure 10-4
Creating a Column of the circle Opaque Data Type


INFORMIX-ESQL/C Programmer's Manual, Version 9.21
Copyright © 1999, Informix Software, Inc. All rights reserved