Hi,
I tried your suggestions. However, as I show below I get errors when I execute my UDF.
I have a Java helper method that checks if the error condition has occured and if so it fires some SQL state. Here is a snippet:
public void helpFunction(UDF udf) {
boolean ok = ...
if(!ok) {
udf.setSQLstate("70000"); // own SQL state code
udf.setSQLmessage("invalid state: ...");
}
}
If I don't make these calls to the UDF and I provide valid input to the UDF everything works fine. However, I want to elegantly exit the UDF call when the input is not valid. When I make the setSQLstate() and setSQLmessage() calls, I get the following error when I execute my UDF from within a SQL statement:
SQL4302N Procedure or user-defined function "...", specific name
"...." aborted with an exception "Error in UDF setSQLstate.". SQLSTATE=38501
Apparently the calls to the Java UDF type throw an Exception. When I catch that exception and print the message separately I get the same "Error in UDF setSQLstate". The exception stacktrace also just stops in my own code, not showing any DB2 internals that could be diagnostic.
So, I am still quite puzzled as to what the problem is. I got the same problem when I called the setSQLstate and setSQLmessage methods from within the subclass that is derived from the DB2 UDF type.
EDIT: when I call the setSQLstate() method with the string "02000" everything is fine too. This is described on the following link:
http://publib.boulder.ibm.com/infoce.../r0008987.html. Thus, apparently there must be something wrong the the states that I customly created?
Any suggestions?
Regards,
TR