From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Richard Albright <ralbright(at)insiderscore(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: sql wrapped plpgsql set returning function |
Date: | 2007-04-25 18:32:25 |
Message-ID: | 3415.1177525945@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Richard Albright <ralbright(at)insiderscore(dot)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=#
From | Date | Subject | |
---|---|---|---|
Next Message | Richard Albright | 2007-04-25 18:45:05 | Re: sql wrapped plpgsql set returning function |
Previous Message | Richard Albright | 2007-04-25 18:10:09 | sql wrapped plpgsql set returning function |