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: Tue, 17 Jul 2007 23:50:00 -0500
Message-ID: <c2d9e70e0707172150j4c319010n17f245c6807aef68@mail.gmail.com> (raw)
In-Reply-To: <52149.39195.qm@web88311.mail.re4.yahoo.com>
References: <52149.39195.qm@web88311.mail.re4.yahoo.com>

On 7/17/07, Norm Garand <indianlakesolutions@rogers.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



view thread (5+ messages)  latest in thread

Message-ID: <c2d9e70e0707172150j4c319010n17f245c6807aef68@mail.gmail.com>
Permalink:  ../c2d9e70e0707172150j4c319010n17f245c6807aef68@mail.gmail.com/
Also on:    postgresql.org/message-id/c2d9e70e0707172150j4c319010n17f245c6807aef68@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: <c2d9e70e0707172150j4c319010n17f245c6807aef68@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