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

Поиск
Список
Период
Сортировка
От Jaime Casanova
Тема Re: Inserting an IF statement in the middle of a SELECT in pl/pgSQL code
Дата
Msg-id c2d9e70e0707172150j4c319010n17f245c6807aef68@mail.gmail.com
обсуждение исходный текст
Ответ на Inserting an IF statement in the middle of a SELECT in pl/pgSQL code  (Norm Garand <indianlakesolutions@rogers.com>)
Список pgsql-sql
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


В списке pgsql-sql по дате отправления:

Предыдущее
От: "Rodrigo De León"
Дата:
Сообщение: Re: Inserting an IF statement in the middle of a SELECT in pl/pgSQL code
Следующее
От: Norm Garand
Дата:
Сообщение: A better look at trying to insert a Conditional in a SELECT statement