Robert Enyedi wrote: > Hi, > > According to this post > http://mail-archives.apache.org/mod_mbox/db-derby-user/200602.mbox/[EMAIL > PROTECTED] > I can explicitly state the parameter bindings of a Java function. Can > something similar be done for the return type too? > > For example this statement > > CREATE FUNCTION F1(FIRSTINT INTEGER, SECONDINT INTEGER) RETURNS INTEGER > PARAMETER STYLE JAVA NO SQL LANGUAGE JAVA > EXTERNAL NAME > 'utils.CompatibilityFunctions.f1(java.lang.Integer,java.lang.Integer)'; > > expects that the return type of the utils.CompatibilityFunctions.f1 > method is "int" and _not_ "java.lang.Integer". But this way I cannot > return a NULL value. Is there a workaround for this?
The Java return type of a method cannot be specified in the EXTERNAL NAME clause, this is from section 9.8 of the SQL standard part 13. One possible work around is to use the RETURNS NULL ON NULL INPUT clause which will make the SQL function return NULL if any of the arguments are NULL. Otherwise you should just enter a Jira improvement for the Java method resolution for functions to allow resolving to the object type (java.lang.Integer) as well as the primitive type (int). I believe this is in line with the standard. Even better enter the issue and then work on it, join derby-dev and you will get help there on development issues. Thanks, Dan.
