Re: nvl() function

From: Joel Burton <joel(at)joelburton(dot)com>
To: Steven Dahlin <sdahlin_plsql(at)hotmail(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: nvl() function
Date: 2001-10-17 17:53:38
Message-ID: Pine.LNX.4.30.0110171352110.24721-100000@temp.joelburton.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, 16 Oct 2001, Steven Dahlin wrote:

> I am trying to find the equivalent in Postgresql to the Oracle sql function
> nvl(). With nvl() you give two parameters. The first may be a field/column
> or variable. If the value is not null then it is returned by the function.
> For example the with query below if the :ClientParameter is passed then only
> those rows which have a clientdesc matching the parameter are returned. If
> the :ClientParameter is null then those rows which have clientdesc =
> clientdesc are returned (all rows):
>
> select clientid,
> clientdesc
> from clients
> where ( clientdesc = nvl( :ClientParameter, clientdesc ) )
>
> I have looked thru all the documentation I could find but nowhere were any
> built-in SQL functions delineated. Does anyone know where the documentation
> can be found?

COALESCE is the SQL standard name for this. You'll find details in the
documentation, in the Conditional Expressions section (4.10). Copy at:

http://candle.pha.pa.us/main/writings/pgsql/sgml/functions-conditional.html

--

Joel BURTON | joel(at)joelburton(dot)com | joelburton.com | aim: wjoelburton
Independent Knowledge Management Consultant

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jason Earl 2001-10-17 18:20:51 Re: Triggers do not fire
Previous Message Joel Burton 2001-10-17 17:51:13 Re: Multiple Parameters to an Aggregate Function