Re: Returning SETOF INTEGER mystery...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Juan Francisco Diaz <j-diaz(at)publicar(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Returning SETOF INTEGER mystery...
Date: 2003-08-28 03:58:11
Message-ID: 18957.1062043091@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Juan Francisco Diaz <j-diaz(at)publicar(dot)com> writes:
> Hello again, i found ou that no matter the function, if the return type is a
> SETOF INTEGER, or a SETOF CUSTOMTYPE that includes at least ONE INTEGER
> value, the error:

> WARNING: plpgsql: ERROR during compile of buscarseccion near line 6
> ERROR: missing .. at end of SQL expression

Hm. This implies that the plpgsql parser thinks you're making a
for-loop-over-integer, which is what it will think if the name appearing
just after FOR is not a known plpgsql variable. This doesn't seem to
be the case here though:

> CREATE OR REPLACE FUNCTION BUSCarSeccion(VARCHAR) RETURNS SETOF
> BusCarSeccion AS '
> DECLARE
> Libro ALIAS FOR $1;
> res BusCarSeccion;
> BEGIN
> FOR res IN select alto,altoIntercita, espacioCabeza, EspacioFin,

You might be running into the problem mentioned in the "Row Types"
documentation:

: Presently, a row variable can only be declared using the %ROWTYPE
: notation; although one might expect a bare table name to work as a type
: declaration, it won't be accepted within PL/pgSQL functions.

But IIRC the symptom of this limitation isn't quite what you're seeing
... if adding %ROWTYPE to "res BusCarSeccion" doesn't fix your problem,
could we see a complete example?

regards, tom lane

PS: the syntax without %ROWTYPE does work as of 7.4.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Tom Lane 2003-08-28 04:28:40 Re: using dates in pgsql
Previous Message Tom Lane 2003-08-28 03:34:07 Re: Upgrading from 7.1.2 to 7.3.3 - function may need to add explicit typecasts