Re: set-returning function in pg 7.4.6 - Mailing list pgsql-novice

From Michael Fuhr
Subject Re: set-returning function in pg 7.4.6
Date
Msg-id 20050314160652.GA45430@winnie.fuhr.org
Whole thread Raw
In response to set-returning function in pg 7.4.6  (Raphael Bauduin <raphael.bauduin@be.easynet.net>)
List pgsql-novice
On Mon, Mar 14, 2005 at 04:50:38PM +0100, Raphael Bauduin wrote:

>    for r in EXECUTE ''select customer_id from customers'' loop

If the query is static (i.e., not generated) and you're not working
with a temporary table, then you can omit EXECUTE:

  FOR r IN SELECT customer_id FROM customers LOOP

The function might benefit from using a cached plan in this case.

> select GetRows();
>
> I get this error:
>
> ERROR:  set-valued function called in context that cannot accept a set
> CONTEXT:  PL/pgSQL function "getrows" line 5 at return next

It should be:

SELECT * FROM GetRows();

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

pgsql-novice by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: set-returning function in pg 7.4.6
Next
From: "Christian Hofmann"
Date:
Subject: Problem: Joining each column of a "one row query" with the result of a "many row query"