Operators on user-defined data types
You can extend an existing operator to operate on a UDT. When you define the appropriate operator function, operator binding enables SQL statements to use both the function name and its operator symbol on the UDT. You can write operator functions in SPL or an external language.
For example, suppose you create a data type, called Scottish,
that represents Scottish names, and you want to order the data type
in a different way than the U.S. English collating sequence. You might
want the names McDonald
and MacDonald
to
appear together on a phone list. The default relational operators
(for example, =) for character strings do not achieve this ordering.
To cause Mc
and Mac
to appear
together, you can create a compare() function that
compares two Scottish-name values and treats Mc
and Mac
identically.
The database server uses the compare (Scottish, Scottish) function
when it compares two Scottish-name values. If you define a compare() function,
you must also define the greaterthan(), lessthan(), equal() or
other functions that use the compare function.
Routine overloading is the ability to use the same name for multiple functions to handle different data types.