Runtime versus compile-time datatypes

Neither widening nor narrowing conversions modify the actual instance value or its runtime datatype; they simply specify the class to be used for the compile-time type. Thus, when you store Address2Line values from the mailing_addr column into the home_address column, those values still have the runtime type of Address2Line.

For example, the Address class and the Address2Line subclass both have the method toString( ), which returns a String form of the complete address data.

select name, home_addr>>toString( )  from emps
 	where home_addr>>toString( ) not like '%Line2=[ ]'

For each row of emps, the declared type of the home_addr column is Address, but the runtime type of the home_addr value is either Address or Address2Line, depending on the effect of the previous update statement. For rows in which the runtime value of the home_addr column is an Address, the toString( ) method of the Address class is invoked, and for rows in which the runtime value of the home_addr column is Address2Line, the toString( ) method of the Address2Line subclass is invoked.

See “Null values when using the SQL convert function” for a description of null values for widening and narrowing conversions.