Re: SQL plan in functions

Поиск
Список
Период
Сортировка
От Raymond O'Donnell
Тема Re: SQL plan in functions
Дата
Msg-id 494A4066.909@iol.ie
обсуждение исходный текст
Ответ на Re: SQL plan in functions  (Julius Tuskenis <julius.tuskenis@gmail.com>)
Ответы Re: SQL plan in functions  (Julius Tuskenis <julius.tuskenis@gmail.com>)
Список pgsql-general
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@iol.ie
Galway Cathedral Recitals: http://www.galwaycathedral.org/recitals
------------------------------------------------------------------

В списке pgsql-general по дате отправления:

Предыдущее
От: Julius Tuskenis
Дата:
Сообщение: Re: SQL plan in functions
Следующее
От: Alvaro Herrera
Дата:
Сообщение: Re: Missing usenet messages. Was: A bit confused about Postgres Plus