Re: plpgsql functions - Mailing list pgsql-general

From Raymond O'Donnell
Subject Re: plpgsql functions
Date
Msg-id 48A5EB74.8030804@iol.ie
Whole thread Raw
In response to plpgsql functions  ("c k" <shreeseva.learning@gmail.com>)
Responses Re: plpgsql functions  (Christophe <xof@thebuild.com>)
List pgsql-general
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
------------------------------------------------------------------

pgsql-general by date:

Previous
From: Raymond O'Donnell
Date:
Subject: Re: syntax error at or near "PERFORM"
Next
From: "Roderick A. Anderson"
Date:
Subject: Re: [Q] DNS(bind) ER model