[SQL] Need help with plpgsql function.

2010-11-13 Thread berelith
Hi, I'm creating the function on a postgres 8.2 server. I would like the function to accept half a dozen varied parameters (varchars and timestamps). The first parameter will determine which one of the 6 different select queries that function is going to run. The function will return all the row

Re: [SQL] Need help with plpgsql function.

2010-11-13 Thread Pavel Stehule
2010/11/14 berelith : > > Hi, > > I'm creating the function on a postgres 8.2 server. > I would like the function to accept half a dozen varied parameters (varchars > and timestamps). > The first parameter will determine which one of the 6 different select > queries that function is going to run. >

Re: [SQL] Need help with plpgsql function.

2010-11-14 Thread Adrian Klaver
On Saturday 13 November 2010 11:15:51 pm Pavel Stehule wrote: > > } > > Hello > > you can use a RETURN QUERY statement - some like > > CREATE OR REPLACE FUNCTION foo(IN i int, OUT a int, OUT b int) > RETURNS SETOF RECORD AS $$ > BEGIN > IF i = 1 THEN > RETURN QUERY SELECT 10,20 UNION ALL SEL

Re: [SQL] Need help with plpgsql function.

2010-11-14 Thread Pavel Stehule
2010/11/14 Adrian Klaver : > On Saturday 13 November 2010 11:15:51 pm Pavel Stehule wrote: > >> > } >> >> Hello >> >> you can use a RETURN QUERY statement - some like >> >> CREATE OR REPLACE FUNCTION foo(IN i int, OUT a int, OUT b int) >> RETURNS SETOF RECORD AS $$ >> BEGIN >>   IF i = 1 THEN >>