The subtype-treatment is used to cast a structured type expression into one of its subtypes. The static type of expression must be a user-defined structured type, and that type must be the same type as, or a supertype of, data-type. If the type name in data-type is unqualified, the SQL path is used to resolve the type reference. The static type of the result of subtype-treatment is data-type, and the value of the subtype-treatment is the value of the expression. At run time, if the dynamic type of the expression is not data-type or a subtype of data-type, an error is returned (SQLSTATE 0D000).
SELECT TREAT (CIRCLE_COL AS COLOREDCIRCLE)..RGB()
FROM RINGS
SELECT (CASE
WHEN CIRCLE_COL IS OF (COLOREDCIRCLE)
THEN TREAT (CIRCLE_COL AS COLOREDCIRCLE)..RGB()
ELSE NULL
END)
FROM RINGS