If you need to calculate the cost for a UDR at runtime,
create a cost function.
To create a cost function:
- Write a C user-defined function to implement the cost function.
The cost function has the following coding requirements:
- Register the cost function with the CREATE FUNCTION statement.
The SQL cost function has the following registration requirements:
- The cost function must take the same number of arguments as its
companion UDR.
- Each argument of the cost function must be declared of type SELFUNCARG.
- The cost function must return the cost as an INTEGER or SMALLINT
value.
- Associate the cost function with its companion UDR with
the COSTFUNC routine modifier when you register the companion UDR.