Relational operators

Relational operators operate on expressions of numeric and string values. The following table lists the operator functions that the database server provides.
Relational operator Operator function
= equal()
<> and != notequal()
> greaterthan()
< lessthan()
>= greaterthanorequal()
<= lessthanorequal()

All relational operator functions must return a Boolean value. For more information about relational operators, see the Relational Operator segment in the HCL OneDB™ Guide to SQL: Syntax.

For end users to be able to use values of a new data type with relational operators, you must write new relational-operator functions that can handle the new data type. In these functions, you can:
  • Determine what the relational operators mean for that data type.

    For example, you might create the circle opaque data type to implement a circle. A circle is a spatial object that does not have a single value to compare. However, you can define relational operators on this data type that can use the value of its area: one circle is less than a second circle if its area is less than the area of the second.

  • Change from lexicographical sequence to some other ordering for a data type.

    For example, suppose you create a data type, ScottishName, that holds 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. You can define relational operators for this data type that equate the strings Mc and Mac. For more information, see Change the sort order.

    After you define the relational operators, you can use SQL statements such as the following one:
    SELECT * FROM employee
       WHERE emp_name = 'McDonald'::ScottishName

The relational-operator functions are strategy functions for the built-in secondary-access method, a generic B-tree. For information about strategy functions, see Operator classes.