Home | Previous Page | Next Page   Creating User-Defined Routines > Creating Special-Purpose UDRs > Providing UDR-Optimization Functions >

Creating Negator Functions

A negator function is a special UDR that is associated with a Boolean user-defined function. It evaluates the Boolean NOT condition for its associated user-defined function. For example, if an expression in a WHERE clause invokes a Boolean user-defined function (UDR-Boolfunc), the SQL optimizer can decide whether it is more efficient to replace occurrences of the expression

NOT (UDR-Boolfunc)

with a call to the negator function (UDR-func-negator).

To implement a negator function with a C user-defined function
  1. Declare the negator function so that its parameters are exactly the same as its associated user-defined function and its return value is BOOLEAN (mi_boolean).
  2. Within the negator function, perform the tasks to evaluate the NOT condition of the associated Boolean user-defined function.
  3. Register the negator function as a user-defined function with the CREATE FUNCTION statement.
  4. Associate the Boolean user-defined function and its negator function when you register the user-defined function.

    Specify the name of the negator function with the NEGATOR routine modifier in the CREATE FUNCTION statement that registers the user-defined function.

For more information about Boolean user-defined functions and negator functions, see the IBM Informix: User-Defined Routines and Data Types Developer's Guide. For information on how to determine if a user-defined function has a negator function, see Checking for a Negator Function.

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