Distinct type operands

A distinct type cannot be used with arithmetic operators even if its source data type is numeric. To perform an arithmetic operation, create a function with the arithmetic operator as its source. For example, if there were distinct types INCOME and EXPENSES, both of which had DECIMAL(8,2) data types, then the following user-defined function, REVENUE, could be used to subtract one from the other.

   CREATE FUNCTION REVENUE ( INCOME, EXPENSES )
     RETURNS DECIMAL(8,2) SOURCE "-" ( DECIMAL, DECIMAL)

Alternately, the - (minus) operator could be overloaded using a user-defined function to subtract the new data types.

   CREATE FUNCTION "-" ( INCOME, EXPENSES )
     RETURNS DECIMAL(8,2) SOURCE "-" ( DECIMAL, DECIMAL)

Alternatively, the distinct type can be cast to a built-in type, and the result can be used as an operand of an arithmetic operator.