From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael J Davis <michael.j.davis@tvguide.com>
Cc: pgsql-general@postgresql.org, "'pgqsl-interfaces@postgreSQL.org'" <pgqsl-interfaces@postgresql.org>
Cc: 'pgsql-sql@postgreSQL.org' <pgsql-sql@postgresql.org>
Subject: Re: [SQL] RE: [GENERAL] Two variable passed to PL/Function and on is NULL
Date: Mon, 14 Jun 1999 17:20:38 -0400
Message-ID: <21113.929395238@sss.pgh.pa.us> (raw)
In-Reply-To: <93C04F1F5173D211A27900105AA8FCFC1455CD@lambic.prevuenet.com>
Michael J Davis <michael.j.davis@tvguide.com> writes:
> Create an nz(int4) or nvl(int4) function that returns 0 if $1 is null.
> You could also create nz(text) that returns '' when $1 is null.
Also, you can use the COALESCE() standard function to handle this sort
of thing: COALESCE(a,b,...) basically returns the first non-null value
in its argument list. So COALESCE(x,0) or COALESCE(x,'') would handle
the above requirements.
COALESCE is a shorthand form of a CASE expression, which allows for
even more general if-then-else calculations.
CASE is present but a tad buggy in 6.4 (IIRC, it fails if used in a
SELECT that joins more than one table). There are no known problems
with it in 6.5.
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, michael.j.davis@tvguide.com, pgqsl-interfaces@postgresql.org
Subject: Re: [SQL] RE: [GENERAL] Two variable passed to PL/Function and on is NULL
In-Reply-To: <21113.929395238@sss.pgh.pa.us>
References: <93C04F1F5173D211A27900105AA8FCFC1455CD@lambic.prevuenet.com> <21113.929395238@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