Re: Error with returning SETOF Record

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: A E <cooljoint(at)yahoo(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Error with returning SETOF Record
Date: 2003-12-27 21:19:17
Message-ID: 13840.1072559957@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

A E <cooljoint(at)yahoo(dot)com> writes:
> CREATE FUNCTION tester(varchar) RETURNS SETOF record as'
> DECLARE
> ft record;
> begin
> FOR ft IN SELECT * FROM visaapplicants LOOP
> RETURN NEXT ft;
> END LOOP;
> return null;
> end;'
> LANGUAGE 'plpgsql' VOLATILE;

> <calling query>
> select * from tester('a') as (c varchar);

> <exact error>
> ERROR: wrong record type supplied in RETURN NEXT
> CONTEXT: PL/pgSQL function "tester" line 6 at return next

That's pretty much what I'd expect, unless table visaapplicants contains
only a single varchar column. The example works fine for me if I define
visaapplicants that way.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Manfred Spraul 2003-12-27 21:36:36 Re: update i386 spinlock for hyperthreading
Previous Message Joe Conway 2003-12-27 21:18:18 Re: [GENERAL] Strange permission problem regarding pg_settings