Restrictions on user-defined casts

You cannot create a user-defined cast between two built-in data types. You also cannot create a user-defined cast that includes any of the following data types:
  • Collection data types: LIST, MULTISET, or SET
  • Unnamed row types
  • Smart-large-object data types: CLOB or BLOB
  • Simple-large-object data types: TEXT or BYTE

In general, a cast between two data types requires that each data type represents the same number of component values. For example, a cast between a row type and an opaque data type is possible if each field in the row type has a corresponding field in the opaque data type. When you want to perform conversions between two data types that have the same storage structure, you can use the CREATE CAST statement without a cast function. Otherwise, you must create a cast function that you then register with a CREATE CAST statement. For an example of how to use a cast function to create a user-defined cast, see Create cast functions for user-defined casts.