To register user defined scalar functions In an IP developed in Java:
1. Implement the optional method ipGetScalarFunction as part of the IP class. Refer to "ipGetScalarFunction" in the OpenAccess SDK SQL Engine Programmer’s Reference for Java for information on using this method.
2. In the ipGetScalarFunctions method, create an array of type scalar_function and set one item for each scalar function you have defined.
/* Register it */
public scalar_function[] ipGetScalarFunctions()
{
scalar_function[] MyFuncs = new scalar_function[3];
MyFuncs[0] = new scalar_function("INTVAL",1,"ip_func_intval",XO_TYPE_INTEGER,1);
return MyFuncs;
}
/* Implementation of INTVAL scalar function
* out = INTVAL(a) – out is returned same as the input value.
*/
public long ip_func_intval(long hstmt,long pMemTree,long hValExpList)
3. Optionally, in the ipGetScalarFunctions method, create an array of type scalar_function and set one item for each scalar function with a qualifier that you have defined.
/* Register it */
public scalar_function[] ipGetScalarFunctions()
{
scalar_function[] MyFuncs = new scalar_function[2];
MyFuncs[0] = new scalar_function("INTEGER", "ADD", 1, "ip_func_Integer_add",
XO_TYPE_INTEGER, 1);
MyFuncs[1] = new scalar_function("STRING", "ADD", 1, "ip_func_String_add",