db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rick Hillegas <rick.hille...@oracle.com>
Subject Re: varargs functions: primitive or Object type?
Date Mon, 06 Jan 2014 14:09:57 GMT
On 1/6/14 4:47 AM, Tim Dudgeon wrote:
> 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
>
>
>
Thanks for tripping across this, Tim. Looks like there's a bug in here. 
Works for Integer args but not Double args. Stand by while I take a look...

Thanks,
-Rick

Mime
View raw message