Example 1: Assume that distinct type HATSIZE is defined and is based on the built-in data type INTEGER. An AVG function could be defined to compute the average hat size of different departments. Create a sourced function that is based on built-in function AVG.
CREATE FUNCTION AVG (HATSIZE) RETURNS HATSIZE SOURCE AVG (INTEGER)
The syntax of the SOURCE clause includes an explicit parameter list because the source function is a built-in function.
When distinct type HATSIZE was created, two cast functions were generated, which allow HATSIZE to be cast to INTEGER for the argument and INTEGER to be cast to HATSIZE for the result of the function.
Example 2: After Smith created the external scalar function CENTER in his schema, there is a need to use this function, function, but the invocation of the function needs to accept two INTEGER arguments instead of one INTEGER argument and one DOUBLE argument. Create a sourced function that is based on CENTER.
CREATE FUNCTION MYCENTER (INTEGER, INTEGER) RETURNS DOUBLE SOURCE SMITH.CENTER (INTEGER, DOUBLE);
(C) Copyright IBM Corporation 1992, 2006. All Rights Reserved.