Return a set of values from postgres Function

From: "Derrick Betts" <Derrick(at)grifflink(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: Return a set of values from postgres Function
Date: 2003-07-17 22:30:10
Message-ID: 00b301c34cb5$346b1390$0100a8c0@BigOne
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I want to get a set of values returned from a function. The values (there will need to be four of them) come from 4 separate SELECT statements inside the Function. For example SELECT one INTO variable1 from table1 where ... then SELECT two INTO variable2 from table1 where... At first you might think I could just combine the select statements into one statement, but I can't. I need to pass the results of each separate select statement into distinct variables and return them together to the application.

This is what I'm using but isn't working....

create function allincomes(int4) RETURNS setof RECORD AS '

declare

vResult RECORD;

begin

select into vResult CAST(monthly AS varchar) as w2client

from income

where caseid = $1

and incometype = ''W2''

and who = ''Client'';

select into vResult CAST(monthly AS varchar) as selfemployedclient

from income

where caseid = $1

and incometype = ''Self Employed''

and who = ''Client'';

return ;

end;

'

language 'plpgsql';

Any ideas?

Thanks,
Derrick

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Greg Stark 2003-07-18 06:00:23 Re: Recursive request ...
Previous Message Jonathan Gardner 2003-07-17 21:37:01 Re: parse error for function def