Cast between other 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. You can write cast functions in SPL or in external languages. For example, you can define casts for any of the following UDTs:
  • Opaque data types

    You can create casts to convert a UDT to other data types in the database. Developers of opaque data types must also provide functions that serve as cast functions between the internal and external representations of the opaque type. For more information, see Create an opaque data type.

  • Distinct data types

    The database server cannot directly compare a distinct type to its source type. However, the database server automatically registers explicit casts from the distinct type to the source type and conversely. 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.

  • Named row types

    You can create casts to convert a named row data type to another type. For information about how to cast between named row types and unnamed row types, see the Informix® Guide to SQL: Tutorial.

For more information about how to create and register casts on extended data types, refer to Create user-defined casts.