Distinct type operands

Start of changeA weakly typed distinct type operand can be used with arithmetic operators, provided that the source type of the weakly typed distinct type is supported by the arithmetic operator. End of change

A Start of changestrongly typedEnd of change 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 overridden 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.