DB2 10.5 for Linux, UNIX, and Windows

Subtype treatment

The subtype-treatment is used to cast a structured type expression into one of its subtypes.

Read syntax diagramSkip visual syntax diagram
subtype-treatment

|--TREAT--(--expression--AS--data-type--)-----------------------|

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).

Example