Home | Previous Page | Next Page   Creating an Opaque Data Type > Creating an Opaque Data Type >

Registering the Opaque Data Type with the Database

After you create the internal structure and support functions for the opaque data type, use the following SQL statements to register them with the database:

Registering the Opaque Data Type

To create an opaque data type within a database, you must have the Resource privilege on the database. The CREATE OPAQUE TYPE statement registers an opaque data type with the database. It provides the following information to the database:

The CREATE OPAQUE TYPE statement stores this information in the sysxtdtypes system catalog table. When it stores a new opaque data type in sysxtdtypes, the CREATE OPAQUE TYPE statement causes a unique value, called an extended identifier, to be assigned to the opaque data type. Throughout the system catalog, an opaque data type is identified by its extended identifier, not by its name. (For more information on the columns of the sysxtdtypes system catalog, see the chapter on system catalog tables in the IBM Informix: Guide to SQL Reference.)

To register a new opaque data type in a database, you must have the Resource privilege on that database. By default, a new opaque data type has Usage permission assigned to the owner. For information on how to change the permission of an opaque data type, see Granting Privileges for an Opaque Data Type.

For more information on the syntax of the CREATE OPAQUE TYPE, CREATE FUNCTION, and CREATE FUNCTION FROM statements, see their descriptions in the IBM Informix: Guide to SQL Syntax.

Creating Casts for Opaque Data Types

For each of the support functions in the following table, the database server uses a cast to convert the opaque data type to a particular internal data type.

Support Function Cast
From To Type of Cast
input LVARCHAR opaque data type implicit
output opaque data type LVARCHAR explicit
receive SENDRECV opaque data type implicit
send opaque data type SENDRECV explicit
import IMPEXP opaque data type implicit
export opaque data type IMPEXP explicit
importbinary IMPEXPBIN opaque data type implicit
exportbinary opaque data type IMPEXPBIN explicit
streamread STREAM opaque data type implicit
streamwrite opaque data type STREAM explicit

For the database server to perform these casts, you must create the casts with the CREATE CAST statement. The database server can then call the appropriate support function when it needs to cast opaque-type data to or from the LVARCHAR, SENDRECV, IMPEXP, IMPEXPBIN, or STREAM data types.

The CREATE CAST statement stores information about cast functions in the syscasts system catalog table. For more information on the CREATE CAST statement, see the description in the IBM Informix: Guide to SQL Syntax. For a description of casting, see the IBM Informix: Guide to SQL Tutorial.

Using Non In-Row Storage

An opaque data type can use the following types of non in-row storage:

The routines that support the opaque data type should do the following:

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]