I'm experiencing some puzzling behaviour with some of my UDFs when
declaring them as ATOMIC.. Basically I'm invoking another UDF (which
uses some Java code) in one branch of a CASE statment, and if that UDF
is declared as ATOMIC then both branches get executed!
I've put together some simple SQL (see below) which shows this. When I
invoke "select bar(cast (null as integer)) from sysibm.sysdummy1" I get
this error:
SQL0470N The user defined routine "BAZ" (specific name
"SQL050825134727100") has a null value for argument "1" that could not
be
passed. SQLSTATE=39004
So it seems that even though I passed in a null value, the other CASE
branch got executed. But.. if I change bar to use foo2() instead, it
works as expected.
Any ideas? btw, I'm running DB2 8.1.0 on AIX
Thanks!
Seenu
CREATE FUNCTION BAZ (INTEGER) RETURNS VARCHAR(5)
LANGUAGE Java
EXTERNAL NAME 'Dummy!printInt'
PARAMETER STYLE JAVA
/
CREATE FUNCTION FOO1 (
inputData INTEGER
)
RETURNS VARCHAR(5)
F1: BEGIN ATOMIC
RETURN
BAZ(inputData);
END
/
CREATE FUNCTION FOO2 (
inputData INTEGER
)
RETURNS VARCHAR(5)
RETURN
BAZ(inputData)
/
CREATE FUNCTION BAR (
inputData INTEGER
)
RETURNS VARCHAR(5)
RETURN
CASE
WHEN inputData IS NULL THEN
NULL
ELSE
foo1(inputData)
-- foo2(inputData)
END
/