Example: Using UDTs in UNION
Suppose that you want to provide your U.S. users with a query to show the sales of every product of your company. The SELECT statement is as follows:
SELECT PRODUCT_ITEM, MONTH, YEAR, TOTAL FROM US_SALES UNION SELECT PRODUCT_ITEM, MONTH, YEAR, US_DOLLAR (TOTAL) FROM CANADIAN_SALES UNION SELECT PRODUCT_ITEM, MONTH, YEAR, US_DOLLAR (TOTAL) FROM GERMAN_SALESYou cast Canadian dollars to U.S. dollars and Euros to U.S. dollars because UDTs are union compatible only with the same UDT. You must use the functional notation to cast between UDTs since the cast specification only allows you to cast between UDTs and their source types.
Parent topic:
Examples: Using UDTs