Defining sourced UDFs for distinct types

This section provides information about defining sourced UDFs for distinct types.

About this task

Suppose you have defined a sourced UDF on the built-in SUM function to support SUM on euros:
     CREATE FUNCTION SUM (EUROS) 
       RETURNS EUROS 
       SOURCE SYSIBM.SUM (DECIMAL())
You want to know the total of sales in Germany for each product in the year of 1994. You would like to obtain the total sales in US dollars:
     SELECT PRODUCT_ITEM, US_DOLLAR (SUM (TOTAL)) 
       FROM GERMAN_SALES 
       WHERE YEAR = 1994 
       GROUP BY PRODUCT_ITEM

You could not write SUM (us_dollar (total)), unless you had defined a SUM function on US dollar in a manner similar to that in the previous example.