Tom Hughes wrote:
> In message <[EMAIL PROTECTED]>
>           Chaim Frenkel <[EMAIL PROTECTED]> wrote:
>
> > I'd like to be able to mimic what the rules for nulls are in databases.
> > (I only know sybase's rules, so there may be differences between
vendors.
> > Could somone that is aware of the ANSI standard chime in.)
>
> > value == NULL : false
>
> Surely value == NULL is true iff value really is a null?
>
No. NULL isn't equal to anything! In SQL, you can only say 'value IS NULL'.

> > NULL == NULL : false
>
> Always true surely?
>
Still no. It is only true that 'NULL is NULL', not 'NULL==NULL'.

> > value != NULL : false
> > NULL != NULL : false
>
> As for the above cases but inverted.
>
> Using <, >, <= and >= with a null does always give false though IIRC.
>
Correct. NULL is not equal to anything, smaller than anything, or greater
than anything. It's null--there's nothing there to compare to!

> > In sybase, summing or averaging a column with nulls simply ignores the
> > nulls. How this would effect the proposed reduce function or perhaps
> > that map/grep functions I don't have a clear proposal.
>
Yes, group functions act on non-nulls only. Not all SQLs support this
behaviour, however. I don't see how this can be applied to reduce(),
however, since sum(@list) is simply:
  reduce __+__, @list;
and perl can't really know that '+' is being called in a 'reduce context'
here.


Reply via email to