Tutorial exercise 2: Creating distinct data types and casts

This exercise demonstrates how to create distinct data types and the casts that convert them. This exercise consists of 14 steps. It takes approximately one hour to complete.

About this task

The example Mercury DataBlade® module contains distinct data types to represent Fahrenheit and Celsius temperatures and casts to convert between the two.

You create the distinct data type hierarchy, beginning with the temperature distinct data type, which is based on the built-in double precision data type.

Then you create the CTemp and FTemp types that inherit from temperature, as shown in the following diagram.
Figure 1: A primary and secondary database server in a data replication configuration

begin figure description - This figure is described in the surrounding text. - end figure description

The Mercury DataBlade module ensures that users cannot enter temperatures below absolute zero in the CTemp and FTemp types. If a user attempts to insert an incorrect value, the INSERT statement fails and returns an error. The DataBlade module uses user-defined support routines and casts to check the input value.