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

From: "Jaime Casanova" <systemguards(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:50:00
Message-ID: c2d9e70e0707172150j4c319010n17f245c6807aef68@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:
> In the WHERE portion of the SELECT statment, I'd like to insert the IF statement shown below. I've
> tried single and double quotes and the pipeline for concatenation, but nothing seems to work. Any
> suggestions or resolutions would be greatly appreciated. Please feel free to contact me directly.
>

use CASE

baan=# create function t(con_stock boolean) returns setof ttdinv001214 as $$
baan$# select * from ttdinv001214
baan$# where substring(trim(t_item), 1, 3) = 'DPP'
baan$# and case $1 when true then t_stoc > 0 else t_stoc = 0 end;
baan$# $$ language sql;
CREATE FUNCTION

--
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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Norm Garand 2007-07-18 05:33:00 A better look at trying to insert a Conditional in a SELECT statement
Previous Message Rodrigo De León 2007-07-18 04:46:44 Re: Inserting an IF statement in the middle of a SELECT in pl/pgSQL code