Extending an existing operator class

About this task

You can define operator-class functions of an operator class only for existing data types. When you create a UDT, you must determine whether you need to create operator-class functions for this data type. The creation of new operator-class functions that have the same names as the existing operator class functions is the most common way to extend an existing operator class.

To extend the functionality of an operator-class function, write a function that has the same name and return value. You provide parameters for the new data type and write the function to handle the new parameters. Routine overloading allows you to create many functions, all with the same name but each with a different parameter list. The database server then uses routine resolution to determine which of the overloaded functions to use based on the data type of the value. For more information about routine overloading and routine resolution, see Run a user-defined routine.

To define operator-class functions for a user-defined data type:

Procedure

  1. Decide which of the secondary-access methods can support the UDT.
  2. Extend the operator classes of the chosen secondary-access method or methods.

    To allow end users to use the user-defined type with the operators that are associated with the secondary-access method, write new strategy and support functions to handle this new data type.