implementing a negator function with a C user-defined function
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.
About this task
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:
Procedure
- 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).
- Within the negator function, perform the tasks to evaluate the NOT condition of the associated Boolean user-defined function.
- Register the negator function as a user-defined function with the CREATE FUNCTION statement.
- 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.
Results
For more information about Boolean user-defined functions and negator functions, see the Informix® User-Defined Routines and Data Types Developer's Guide. For information about how to determine if a user-defined function has a negator function, see Determine if a function is a negator function.