Configurable Functions
DataCaster supports configurable functions via the functions.xml config file in the db directory. This allows specifying static or non-static Java methods be invoked when SQL functions are used in SQL statements. These functions are available in all databases to all users. These are in addition to a few built-in functions that are in the core product.
This functions.xml conf file specifies the list of configured Functions, each of which needs a FunctionClass instance to implement the function. The supported attributes of Function are:
- name: Function name used to specify the function.
- FunctionClass: The class name of the Function class to be used, which must have a no-arg constructor if the method used is not static.
The FunctionProperty tags in the configuration of each function are as follows:
- MethodName: Required parameter for the method name to be used.
- ReturnType: Required parameter for the return type of the function.
For each function a set of zero or more Argument elements are specified. The Argument element has the following attributes
- name: The name of the argument, which is useful only to store the data in the system catalogs and hence must be unique across all Arguments in a method.
- type: The SQL data type of the argument.
Sample XML for a Function
The following is a sample of the XML for a function called MYMIN that call java.lang.Math.min as detailed below.
<Functions>
<Function name="MYMIN" FunctionClass="java.lang.Math">
<FunctionProperty name="MethodName" value="min" />
<FunctionProperty name="ReturnType" value="INTEGER" />
<Argument name="arg1" Type="INT">
<ArgumentProperty name="Direction" value="IN" />
</Argument>
<Argument name="arg2" Type="INT">
</Argument>
</Function>
</Functions>