From: Tom Lane <tgl@sss.pgh.pa.us>
To: Albert REINER <areiner@tph.tuwien.ac.at>
Cc: PostgreSQL-SQL <pgsql-sql@postgreSQL.org>
Cc: Thomas Lockhart <lockhart@alumni.caltech.edu>
Subject: Re: [SQL] IFNULL - problem
Date: Sun, 26 Sep 1999 20:04:53 -0400
Message-ID: <21872.938390693@sss.pgh.pa.us> (raw)
In-Reply-To: <19990926172837.A261@frithjof>
"Albert REINER" <areiner@tph.tuwien.ac.at> writes:
> Hi, I'm using PostgreSQL 6.5.1, and when I try to use IFNULL (listed
> in the SQL Functions section of the docs in
The docs are in error: it's spelled NULLIF. In fact they also get
the definition wrong. The SQL92 spec says
1) NULLIF (V1, V2) is equivalent to the following <case specifica-
tion>:
CASE WHEN V1=V2 THEN NULL ELSE V1 END
which is not what you were expecting ... and not terribly useful IMHO,
but that's how the spec defines it. You probably want to use COALESCE
instead:
2) COALESCE (V1, V2) is equivalent to the following <case specifi-
cation>:
CASE WHEN V1 IS NOT NULL THEN V1 ELSE V2 END
3) COALESCE (V1, V2, . . . ,n ), for n >= 3, is equivalent to the
following <case specification>:
CASE WHEN V1 IS NOT NULL THEN V1 ELSE COALESCE (V2, . . . ,n )
END
Note to doc maintainers: glimpse shows these references to 'ifnull':
doc/src/sgml/admin.sgml: Include mention of CASE, COALESCE, and IFNULL.
doc/src/sgml/func.sgml: <entry> IFNULL(<replaceable class="parameter">input</replaceable>,<replaceable class="parameter">non-NULL substitute</replaceable>) </entry>
doc/src/sgml/func.sgml: <entry> IFNULL(<replaceable class="parameter">c1</replaceable>, 'N/A')</entry>
src/bin/pgaccess/lib/help/sqlfunc.hlp: " {} "IFNULL(input,non-NULL substitute)" {bold} "
src/bin/pgaccess/lib/help/sqlfunc.hlp: IFNULL(c1, 'N/A')
Both func.sgml and sqlfunc.hlp give incorrect definitions as well as
giving the wrong spelling.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, areiner@tph.tuwien.ac.at, lockhart@alumni.caltech.edu
Subject: Re: [SQL] IFNULL - problem
In-Reply-To: <21872.938390693@sss.pgh.pa.us>
References: <19990926172837.A261@frithjof> <21872.938390693@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox