INFORMIX
Extending Informix-Universal Server: Data Types
Chapter 3: Creating User-Defined Casts
Home Contents Index Master Index New Book

What Is a User-Defined Cast?

Create a user-defined cast to perform data conversion from one data type to another. You create a user-defined cast with the CREATE CAST statement, which registers the cast in the database.

The database server provides casts between most of the built-in data types. You can create user-defined casts to perform conversions between most data types, including opaque types, distinct types, row types, and built-in types. User-defined casts are generally used to provide type conversions for the following extended data types:

    When you create an opaque data type, you define casts to handle conversions between the internal and external representations of the opaque type. You might also create casts to handle conversions between the new opaque type and other data types in the database.

    A distinct type cannot be directly compared to its source type. However, the database server automatically registers explicit casts from the distinct type to the source type and vice versa. Although a distinct type inherits the casts and functions of its source type, the casts and functions that you define on a distinct type are not available to its source type. You might also create casts on distinct types to handle conversions between the new distinct type and other data types in the database.

    In most cases, you can explicitly cast a named row type to another row type value without having to create the cast. However, in some cases, you might want to create a cast that allows for comparisons between a named row type and some other data type.

You cannot create a user-defined cast that includes any of the following data types as either the source type or target type for the cast:




Extending Informix-Universal Server: Data Types, version 9.1
Copyright © 1998, Informix Software, Inc. All rights reserved.