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