Home | Previous Page | Next Page   Writing Support Functions >

Comparing Data

The compare() function is an SQL-invoked function that sorts the target data type. The database server uses the compare() function in the CREATE INDEX statement and to execute the following components of the SELECT statement:

For more information on the SELECT statement, see the IBM Informix: Guide to SQL Syntax.

If you define a compare() function, you must also define the greaterthan(), lessthan(), equal or other functions that use the compare function.

For the database server to be able to sort an opaque type, you must define a compare() function that handles the opaque type. The compare() function must follow these rules:

  1. The name of the function must be compare(). However, the name is not case sensitive; the compare() function is the same as the Compare() function.
  2. The function must accept two arguments, each of the data types to be compared.
  3. The function must return an integer value to indicate the result of the comparison, as follows:

The compare() function is the support function for the built-in secondary-access method, B-tree. For more information on the built-in secondary-access method, see Generic B-Tree Index. For more information on how to customize a secondary-access method for an opaque data type, see Using Operator Classes.

Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]