Re: isnull - Mailing list pgsql-sql

From Tom Lane
Subject Re: isnull
Date
Msg-id 28671.954461509@sss.pgh.pa.us
Whole thread Raw
In response to Re: isnull  (Joseph Shraibman <jks@p1.selectacast.net>)
List pgsql-sql
Joseph Shraibman <jks@p1.selectacast.net> writes:
> Ah, I think the documentation that came with 6.5.3 was wrong, because
> http://www.postgresql.org/docs/postgres/functions.htm#AEN2257 has the
> function nullif where ifnull was in my documentation.  I don't get
> errors now, but it just doesn't seem to do it's job.

NULLIF doesn't do what you seem to expect: it is for *creating* nulls,
not removing them.  It produces a null if the two arguments are equal,
else the first argument.

COALESCE is probably the thing you are after: it produces the first
nonnull value among its arguments, reading left to right.

There isn't anything called IFNULL in the SQL92 spec, though there
is an IS NULL test (note space).

No, I didn't choose these names ;-) ... blame the SQL92 authors ...
        regards, tom lane


pgsql-sql by date:

Previous
From: Joseph Shraibman
Date:
Subject: Re: isnull
Next
From: Julie Hunt
Date:
Subject: Re: isnull