Example: Money

 

Suppose that you are writing applications that handle different currencies and want to ensure that DB2® does not allow these currencies to be compared or manipulated directly with one another in queries. Remember that conversions are necessary whenever you want to compare values of different currencies. So you define as many UDTs as you need; one for each currency that you may need to represent:

     CREATE DISTINCT TYPE US_DOLLAR AS DECIMAL (9,2)
     CREATE DISTINCT TYPE CANADIAN_DOLLAR AS DECIMAL (9,2)
     CREATE DISTINCT TYPE EURO AS DECIMAL (9,2)

 

Parent topic:

Defining a UDT