From: Tom Lane <tgl@sss.pgh.pa.us>
To: Richard Albright <ralbright@insiderscore.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: sql wrapped plpgsql set returning function
Date: Wed, 25 Apr 2007 14:32:25 -0400
Message-ID: <3415.1177525945@sss.pgh.pa.us> (raw)
In-Reply-To: <1177524609.17790.1.camel@MSI1036>
References: <1177524609.17790.1.camel@MSI1036>
Richard Albright <ralbright@insiderscore.com> writes:
> I have figured out my looping issue, but am having difficulty wrapping
> my set returning plpgsql function getmovavgset with a getmovavg sql func
> when i run the following:
Hm, worksforme (see attached trivial example). What PG version are you
using?
regards, tom lane
regression=# create function foo() returns setof int8_tbl as $$
regression$# declare r record;
regression$# begin
regression$# for r in select * from int8_tbl loop
regression$# return next r;
regression$# end loop;
regression$# end$$ language plpgsql;
CREATE FUNCTION
regression=# select * from foo();
q1 | q2
------------------+-------------------
123 | 456
123 | 4567890123456789
4567890123456789 | 123
4567890123456789 | 4567890123456789
4567890123456789 | -4567890123456789
(5 rows)
regression=# select foo();
ERROR: set-valued function called in context that cannot accept a set
CONTEXT: PL/pgSQL function "foo" line 4 at return next
regression=# create function foowrap() returns setof int8_tbl as $$
regression$# select * from foo();
regression$# $$ language sql;
CREATE FUNCTION
regression=# select foowrap();
foowrap
--------------------------------------
(123,456)
(123,4567890123456789)
(4567890123456789,123)
(4567890123456789,4567890123456789)
(4567890123456789,-4567890123456789)
(5 rows)
regression=#
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, ralbright@insiderscore.com
Subject: Re: sql wrapped plpgsql set returning function
In-Reply-To: <3415.1177525945@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox