User-defined casts

When the database server does not provide built-in casts to perform conversions between two data types, you can create a user-defined cast to handle the data type conversion. User-defined casts are typically used to provide data type conversions for the following extended data types:
Opaque data types
Developers of opaque data types must define casts to handle conversions between the internal/external representations of the opaque data type. For information about how to create and register casts for opaque data types, see HCL OneDB™ User-Defined Routines and Data Types Developer's Guide.
Distinct data types
You cannot directly compare a distinct data type to its source type. However, automatically registers explicit casts from the distinct type to the source type and vice versa. A distinct type does not inherit the casts that are defined on its source type. In addition, the user-defined casts that you might define on a distinct type are unavailable to its source type. For more information and examples that show how to create and use casts on distinct types, see Create cast functions for user-defined casts.
Named row types
In most cases, you can explicitly cast a named row type to another row-type value without creating the cast. However, to convert between values of a named row type and some other data type, you must first create the cast to handle the conversion.

For an example of how to create and use a user-defined cast, see An example of casting between distinct data types. For the syntax of the CREATE CAST statement, see the HCL OneDB Guide to SQL: Syntax.