Register the statprint() function
As with any user-defined function, you register the statistics-display function with the CREATE FUNCTION statement.
The registration of this function has the following requirements:
- You must name this user-defined function statprint.
The database server handles routine resolution based on the data type of the first argument to statprint(). If the name of your C statistics-collection function is not statprint(), specify the C function name in the EXTERNAL NAME clause.
- The data types of the parameters must be as follows.
Parameter number Parameter data type 1 SQL name for the user-defined data type 2 stat - The function must return a value of type LVARCHAR.
The following CREATE FUNCTION statement registers a statistics-display
function:
CREATE FUNCTION statprint(ll_arg longlong, num_rows stat)
RETURNING LVARCHAR
EXTERNAL NAME '/usr/udrs/bin/longlong.so(stat_print_ll)'
LANGUAGE C;
After you register the statprint() function, make sure those with the DBA privilege and the table owner have the Execute privilege for the function.