Re: Newbie Q:"RETURN cannot have a parameter in function returning set"?

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Sigurður Reynisson <siggir(at)gmail(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Newbie Q:"RETURN cannot have a parameter in function returning set"?
Date: 2005-06-22 00:35:51
Message-ID: 20050622003551.GA83681@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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/

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Kirti Pankhania 2005-06-22 05:31:43 Ubuntu problems with Postgres install
Previous Message Michael Fuhr 2005-06-22 00:18:46 Re: Raise Notice