Re: Newbie Q:"RETURN cannot have a parameter in function returning set"? - Mailing list pgsql-novice

From Michael Fuhr
Subject Re: Newbie Q:"RETURN cannot have a parameter in function returning set"?
Date
Msg-id 20050622003551.GA83681@winnie.fuhr.org
Whole thread Raw
In response to Newbie Q:"RETURN cannot have a parameter in function returning set"?  (Sigurður Reynisson <siggir@gmail.com>)
List pgsql-novice
On Tue, Jun 21, 2005 at 08:04:07PM +0000, Sigurður Reynisson wrote:
>
> Warning: pg_query() [function.pg-query]: Query failed: ERROR: RETURN
> cannot have a parameter in function returning set; use RETURN NEXT at
> or near "I" at character 550
...
>  END LOOP;
>  RETURN I;
> END;$BODY$

See "Returning From a Function" in the PL/pgSQL documentation:

http://www.postgresql.org/docs/8.0/static/plpgsql-control-structures.html#PLPGSQL-STATEMENTS-RETURNING

"When a PL/pgSQL function is declared to return SETOF sometype, the
procedure to follow is slightly different.  In that case, the
individual items to return are specified in RETURN NEXT commands,
and then a final RETURN command with no argument is used to indicate
that the function has finished executing."

Change that last "RETURN I" to "RETURN".  PostgreSQL 8 is pickier
about PL/pgSQL syntax than previous versions.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

pgsql-novice by date:

Previous
From: Michael Fuhr
Date:
Subject: Re: Raise Notice
Next
From: Kirti Pankhania
Date:
Subject: Ubuntu problems with Postgres install