Re: PostgreSQL Functions / PL-Language - Mailing list pgsql-general

From Michael Fuhr
Subject Re: PostgreSQL Functions / PL-Language
Date
Msg-id 20060220070711.GA31482@winnie.fuhr.org
Whole thread Raw
In response to Re: PostgreSQL Functions / PL-Language  ("Jan Cruz" <malebug@gmail.com>)
List pgsql-general
On Mon, Feb 20, 2006 at 02:36:04PM +0800, Jan Cruz wrote:
> BTW I also got something like this:
>
> CREATE FUNCTION func2() RETURNS SETOF foo as $$
> DECLARE
> row foo;
> BEGIN
>   SELECT INTO ROW * from FOO;
>    return next foo;
> END;
> $$ LANGUAGE plpgsql STABLE;

Please post the actual code instead of "something like" it.  Trying
to create the above function fails; I'm guessing you really have
"return next row" instead of "return next foo".

> select * from func2();
>
> It did return the 2 rows (all rows) when I first test it.
> Then today I tried the same function  and test it then it return only 1 row.

As written the function above should return only one row because
it doesn't loop through the results.  I suspect the difference
between the earlier test and the most recent one is that you removed
the loop.

--
Michael Fuhr

pgsql-general by date:

Previous
From: "Jan Cruz"
Date:
Subject: Re: PostgreSQL Functions / PL-Language
Next
From: "Virag Saksena"
Date:
Subject: psql Copy question