From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Michael J Davis <michael(dot)j(dot)davis(at)tvguide(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org, "'pgqsl-interfaces(at)postgreSQL(dot)org'" <pgqsl-interfaces(at)postgresql(dot)org>, "'pgsql-sql(at)postgreSQL(dot)org'" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: [SQL] RE: [GENERAL] Two variable passed to PL/Function and on is NULL |
Date: | 1999-06-14 21:20:38 |
Message-ID: | 21113.929395238@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general pgsql-sql |
Michael J Davis <michael(dot)j(dot)davis(at)tvguide(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Hub.Org News Admin | 1999-06-14 21:48:51 | |
Previous Message | Steffen Zimmert | 1999-06-14 21:11:47 | New Release 6.5 |
From | Date | Subject | |
---|---|---|---|
Next Message | Vikrant Rathore | 1999-06-15 03:17:08 | Mail about typecast |
Previous Message | Fomichev Michael | 1999-06-14 20:46:49 | Re: [SQL] OUTER JOINs in PostgreSQL |