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 | c2d9e70e0707181940x4cc70527ka211e1789f3f2237@mail.gmail.com обсуждение исходный текст |
Ответ на | Re: Inserting an IF statement in the middle of a SELECT in pl/pgSQL code ("Jaime Casanova" <systemguards@gmail.com>) |
Список | pgsql-sql |
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
В списке pgsql-sql по дате отправления: