pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jaime Casanova <systemguards@gmail.com>
To: Norm Garand <indianlakesolutions@rogers.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: Inserting an IF statement in the middle of a SELECT in pl/pgSQL code
Date: Wed, 18 Jul 2007 21:40:51 -0500
Message-ID: <c2d9e70e0707181940x4cc70527ka211e1789f3f2237@mail.gmail.com> (raw)
In-Reply-To: <c2d9e70e0707181939p6cfaaa82n50a10ca80ee84f2@mail.gmail.com>
References: <c2d9e70e0707172150j4c319010n17f245c6807aef68@mail.gmail.com>
	<561336.16779.qm@web88309.mail.re4.yahoo.com>
	<c2d9e70e0707181939p6cfaaa82n50a10ca80ee84f2@mail.gmail.com>

sorry, i resubmit to the list

On 7/18/07, Jaime Casanova <systemguards@gmail.com> wrote:
> On 7/18/07, Norm Garand <indianlakesolutions@rogers.com> wrote:
> > Thanks Jaime:
> >
> > I tried using the CASE function and it still didn't work.
> >
> > What I need to do is set a conditional, so that if the parameter is NULL, then the this line is
> > ignored completely and of course the opposite applies, if the value is "something", then this line
> > is included in the SELECT. I've just reworded and resubmitted my question and of course, again, I
> > didn't include the facts above. Thanks, for the response, anything is appreciated.
> >
>
> ok, i will do your work...
>
> CREATE OR REPLACE FUNCTION t(con_stock boolean)
>  RETURNS SETOF ttdinv001214 AS
> $BODY$
> select * from ttdinv001214
> where substring(trim(t_item), 1, 3) = 'DPP'
>  and case $1 when true then t_stoc > 0 else 1 = 1 end;
> $BODY$
>  LANGUAGE 'sql' VOLATILE;
>
>
> note the "else 1=1" part, i could be used "else true" or something else
>
> --
> regards,
> Jaime Casanova
>
> "Programming today is a race between software engineers striving to
> build bigger and better idiot-proof programs and the universe trying
> to produce bigger and better idiots.
> So far, the universe is winning."
>                                       Richard Cook
>


-- 
Atentamente,
Jaime Casanova

"Programming today is a race between software engineers striving to
build bigger and better idiot-proof programs and the universe trying
to produce bigger and better idiots.
So far, the universe is winning."
                                       Richard Cook



view thread (5+ messages)

Message-ID: <c2d9e70e0707181940x4cc70527ka211e1789f3f2237@mail.gmail.com>
Permalink:  ../c2d9e70e0707181940x4cc70527ka211e1789f3f2237@mail.gmail.com/
Also on:    postgresql.org/message-id/c2d9e70e0707181940x4cc70527ka211e1789f3f2237@mail.gmail.com

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: systemguards@gmail.com, indianlakesolutions@rogers.com
  Subject: Re: Inserting an IF statement in the middle of a SELECT in pl/pgSQL code
  In-Reply-To: <c2d9e70e0707181940x4cc70527ka211e1789f3f2237@mail.gmail.com>

* 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