Re: SQL plan in functions

From: Julius Tuskenis <julius(dot)tuskenis(at)gmail(dot)com>
To:
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: SQL plan in functions
Date: 2008-12-18 12:40:39
Message-ID: 494A44C7.7050709@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yes, Raymond - I know how to return record set in function using FOR,
but since version 8.3 there is a option - using RETURN QUERY SELECT
something FROM somewhere;. So if it works for SELECT why should it not
work for EXECUTE ?

Julius Tuskenis

Raymond O'Donnell rašė:
> On 18/12/2008 12:12, Julius Tuskenis wrote:
>
>
>> While experimenting I found that if I wright FOR rec IN EXECUTE 'my sql'
>> LOOP ...... its OK, but If I wright RETURN QUERY EXECUTE 'my sql' I get
>> syntax error. Is it a bug?
>>
>
> No, it's a syntax error. :-)
>
> You need to do something like this to return the rows from the query:
>
> FOR rec in EXECUTE 'your sql here'
> LOOP
> RETURN NEXT rec;
> END LOOP;
>
> RETURN; -- exits from the function.
>
> Ray.
>
>
> ------------------------------------------------------------------
> Raymond O'Donnell, Director of Music, Galway Cathedral, Ireland
> rod(at)iol(dot)ie
> Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
> ------------------------------------------------------------------
>
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Julius Tuskenis 2008-12-18 12:49:29 Re: Error: Operator does not exist: "char"=integer
Previous Message Alvaro Herrera 2008-12-18 12:28:46 Re: Missing usenet messages. Was: A bit confused about Postgres Plus