Re: Inserting an IF statement in the middle of a SELECT in pl/pgSQL code

From: Rodrigo De León <rdeleonp(at)gmail(dot)com>
To: "Norm Garand" <indianlakesolutions(at)rogers(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: Inserting an IF statement in the middle of a SELECT in pl/pgSQL code
Date: 2007-07-18 04:46:44
Message-ID: a55915760707172146n75dbf69btff374c054282bdbf@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 7/17/07, Norm Garand <indianlakesolutions(at)rogers(dot)com> wrote:
> /---------------
> IF $7 IS NOT NULL THEN
> AND f.id = pid.specific_location_cid AND f.long_desc = $7
> END IF
> ---------------/

How about:

AND f.ID = pid.specific_location_cid
AND f.long_desc = COALESCE ($7, f.long_desc)

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jaime Casanova 2007-07-18 04:50:00 Re: Inserting an IF statement in the middle of a SELECT in pl/pgSQL code
Previous Message Norm Garand 2007-07-18 02:42:48 Inserting an IF statement in the middle of a SELECT in pl/pgSQL code