Page 1 of 1

User defined function (UDF) returning 'not null'

PostPosted: Thu Oct 09, 2014 11:48 pm
by bravedreamer
Hey guys,

I have somehow a special problem. Lately I had to write some user defined functions (sql based functions written in PLSQL, not external functions).
The function itself was quite easy. It contained just a lookup for an input parameter in a special table. If the lookup returned a record, the value '1' is returned. Otherwise the value '0'.
So, there will be returned every time a value.

My problem now is, that if I use the UDF in an UNLOAD-Statement, the PUNCH-file contains the additional byte for the indicator.

Is there a way to define a UDF in such a way, that DB2 recognizes it as a function 'that can never return a NULL value'?

Re: User defined function (UDF) returning 'not null'

PostPosted: Wed Oct 22, 2014 4:57 pm
by GuyC
using coalesce(myfunction(blabla),0) in your unload would remove the null-indicator.

Re: User defined function (UDF) returning 'not null'

PostPosted: Wed Oct 22, 2014 5:27 pm
by bravedreamer
Yes, I know that. But I think this is only a workaround.

There should be a way to define the function in the way that DB2 recognizes it al 'never returns NULL'...