If you need to calculate the selectivity for a Boolean
function at run time, create a selectivity function.
To create a selectivity function:
- Write a C user-defined function to implement the selectivity
function.
The selectivity function has the following
coding requirements:
- The selectivity function must take the same number of arguments
as its companion Boolean function.
- Each argument of the selectivity function must be declared of
type MI_FUNCARG.
- The selectivity function must return the selectivity as a floating-point
value (mi_real or mi_double_precision) that is between
zero and one.
- Register the selectivity function with the CREATE FUNCTION
statement.
The SQL selectivity function has the following
registration requirements:
- The selectivity function must take the same number of arguments
as its companion Boolean function.
- Each argument of the selectivity function must be declared of
type SELFUNCARG.
- The selectivity function must return the selectivity as a FLOAT
value.
- Associate the selectivity function with its companion UDR
with the SELFUNC routine modifier when you register the companion
UDR.