Subject | Re: [firebird-support] case when, in, null semantics? |
---|---|
Author | Pavel Menshchikov |
Post date | 2005-03-14T17:51:33Z |
Hello Kjell,
KR> So far, so good. But now this:
KR> case when 'a' in ('b', nullif(1, 1)) then 1 else 0 end
KR> I would expect this to return null, because the null item in the "in"
KR> list could possibly be an 'a', which would return 1. But it actually
KR> returns 0.
KR> Is this really in accordance with the SQL standard?
KR> If it's not, is it an "as designed" deviation from the standard or is it
KR> a bug that will be fixed in the future?
AFAIK, the behavior is correct and standard: NULL is a state, not a
value (you may find the statement in this Yahoo list quite
frequently). It means "unknown", so the "known" ('a') is not equal to
the "unknown" (null) in your case. Also NULL<>NULL. And FB doesn't
know if NULL could possibly be 'a'.
And your CASE WHEN... cannot return NULL at all: the conditon always
is true or false.
HTH
--
Best regards,
Pavel Menshchikov
http://www.ls-software.com
KR> So far, so good. But now this:
KR> case when 'a' in ('b', nullif(1, 1)) then 1 else 0 end
KR> I would expect this to return null, because the null item in the "in"
KR> list could possibly be an 'a', which would return 1. But it actually
KR> returns 0.
KR> Is this really in accordance with the SQL standard?
KR> If it's not, is it an "as designed" deviation from the standard or is it
KR> a bug that will be fixed in the future?
AFAIK, the behavior is correct and standard: NULL is a state, not a
value (you may find the statement in this Yahoo list quite
frequently). It means "unknown", so the "known" ('a') is not equal to
the "unknown" (null) in your case. Also NULL<>NULL. And FB doesn't
know if NULL could possibly be 'a'.
And your CASE WHEN... cannot return NULL at all: the conditon always
is true or false.
HTH
--
Best regards,
Pavel Menshchikov
http://www.ls-software.com