proposal - plpgsql - FOR over unbound cursor

Поиск
Список
Период
Сортировка
От Pavel Stehule
Тема proposal - plpgsql - FOR over unbound cursor
Дата
Msg-id CAFj8pRDQKG-9C4R2yCpthrgFje9aiocahASJJCu6wb-jnuEWkQ@mail.gmail.com
обсуждение исходный текст
Ответы Re: proposal - plpgsql - FOR over unbound cursor  (Asif Rehman <asifr.rehman@gmail.com>)
Re: proposal - plpgsql - FOR over unbound cursor  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi

Last week I played with dbms_sql extension and some patterns of usage cursor in PL/SQL and PL/pgSQL. I found fact, so iteration over cursor (FOR statement) doesn't support unbound cursors. I think so this limit is not necessary. This statement can open portal for bound cursor or can iterate over before opened portal. When portal was opened inside FOR statement, then it is closed inside this statement.

Implementation is simple, usage is simple too:

CREATE OR REPLACE FUNCTION public.forc02()
 RETURNS void
 LANGUAGE plpgsql
AS $function$
declare
  c refcursor;
  r record;
begin
  open c for select * from generate_series(1,20) g(v);

  for r in c
  loop
    raise notice 'cycle body one %', r.v;
    exit when r.v >= 6;
  end loop;

  for r in c
  loop
    raise notice 'cycle body two %', r.v;
  end loop;

   close c;
end
$function$

Comments, notes?

Regards

Pavel

Вложения

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

Предыдущее
От: Paul Guo
Дата:
Сообщение: Re: Two fsync related performance issues?
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: factorial function/phase out postfix operators?