I'm trying to write a function that performs aggregation and I'm not
clear on how to handle the varargs part.
Lets assume I was wanting to write a function that does averaging, and
handles null values correctly.
I'm defining my function like this:
CREATE FUNCTION MYAVG
( VALS DOUBLE ... )
RETURNS DOUBLE
PARAMETER STYLE DERBY
NO SQL LANGUAGE JAVA
EXTERNAL NAME 'myorg.misc.derby.functions.MyFunctions.myAverage;
What does the signature of the Java method need to be?
I've tried:
static Double myAverage(Double[] vals) { }
static Double myAverage(Double... vals) { }
Both of these fail with:
java.sql.SQLSyntaxErrorException: No method was found that matched the
method call myorg.misc.derby.functions.MyFunctions.myAverage(double...),
tried all combinations of object and primitive types and any possible
type conversion for any parameters the method call may have
Seems like its wanting
static Double myAverage(double... vals) { }
but if that's the case how are nulls handled?
Thanks
Tim