Explicit casts on fields
Before you can explicitly cast between two row types (named or unnamed), whose fields contain different data types, a cast (either system-defined or user-defined) must exist to handle conversions between the corresponding field data types.
When you explicitly cast between two row types, the database server automatically invokes any explicit casts that are necessary to handle conversions between field data types. In other words, when you perform an explicit cast on a row type value, you do not have to explicitly cast individual fields of the row type, unless more than one level of casting is necessary to handle the data type conversion on the field.
The row types
and tables in the following example are used throughout this section
to show the behavior of explicit casts on named and unnamed row types:
CREATE DISTINCT TYPE d_float AS FLOAT;
CREATE ROW TYPE row_t (a INT, b d_float);
CREATE TABLE tab1 (col1 ROW (a INT, b d_float));
CREATE TABLE tab2 (col2 ROW (a INT, b FLOAT));
CREATE TABLE tab3 (col3 row_t);