db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Burlison <Alan.Burli...@sun.com>
Subject Re: Returning NULL from a database-side Java function
Date Tue, 09 Oct 2007 17:05:07 GMT
Daniel John Debrunner wrote:

>> won't even compile.  Because you can't assign null to a primitive type 
>> - duh.  Which leaves 2 questions:
>>
>> 1. Why does int pop = 0 == 0 ? 1 : null; even compile?
> 
> Maybe the compiler figures out that it's the same as pop = 1 so it 
> discards the null? Seems like it shouldn't compile.

It even compiles if the contitional isn't a constant expression - most 
odd...

>> 2. How *do* you return a database NULL from a function with a 
>> primitive type as the return type? String isn't a primitive type.
> 
> You need to use the corresponding object type, in this case 
> java.lang.Integer as the return type.

I guessed that might be the case, but haven't had chance to try it - 
thanks for the confirmation.

-- 
Alan Burlison
--

Mime
View raw message