Create a user-defined function (UDF)
You can define functions that are executed against data stored in a table as part of a query result. The function must be created prior to its use in a SELECT statement. The function is performed on each row of the table.
By default, the ability to add user-defined functions is disabled.
To enable, change the following settings in the
Create a function, specifying the data type of the returned value, the language, and the actual code of the function to be performed.
The following function,
fLog(), computes the logarithmic value of each input.
It is a built-in
java function and used to generate linear plots of non-linear data.
For this example, it presents a simple math function to show the capabilities of user-defined functions.
CREATE OR REPLACE FUNCTION cycling.fLog ( input double ) CALLED ON NULL INPUT RETURNS double LANGUAGE java AS $$ return Double.valueOf(Math.log(input.doubleValue())); $$ ;