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:
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 opaque-type name is the name of the data type that SQL statements use. It does not have to be the name of the internal structure for the opaque data type. You might find it useful to create a special prefix to identify the data type as an opaque data type. The opaque-type name must be unique within the name space.
You specify this size information with the INTERNALLENGTH modifier. It indicates whether the data type is a fixed-length or varying-length opaque data type. For more information, see Creating the Internal Structure in C.
The CREATE OPAQUE TYPE statement can specify the following modifiers for an opaque data type: MAXLEN, PASSEDBYVALUE, CANNOTHASH, and ALIGNMENT. You determine this information when you create the internal structure for the opaque data type. For more information, see Creating the Internal Structure in C.
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.
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.
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.
An opaque data type can use the following types of non in-row storage:
For example, this storage type might be a reference to a tape storage system.
For example, this storage type might be a file reference that includes the location of the computer where the user of the reference goes directly to the designated computer, bypassing the database server where the reference is stored.
The routines that support the opaque data type should do the following:
The location information should include the database server name, and, if the data type is dependent on a particular database, the database name.
For example, the open routine must recognize a reference to a remote database server and access it appropriately.