On 15/08/2008 20:12, c k wrote:
> Hi,
> I am getting an error for a function written in plpgsql, as -
>
> CREATE OR REPLACE FUNCTION uf_accgroupbal(date, date, p_company integer)
> RETURNS SETOF uf_closingbal AS
<snip>
For functions return SETOF any type, you need to use the following idiom:
...
declare
rec yourtype;
begin
for rec in [your query here...]
loop
return next rec;
end loop;
return;
end;
...
See the docs on control structures in pl/pgsql.
Ray.
------------------------------------------------------------------
Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
rod@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------