I am trying to loop through a cursor(plpgsql) result,but somehow nothing is being printed on output console.
create or replace function curs() returns refcursor as
$body$
declare
curs cursor for select id from stores;
store stores.id%TYPE;
begin
open curs;
fetch curs into store;
loop
exit when not found;
raise notice 'Value: %',store;
end loop;
close curs;
end
$body$ language plpgsql;
select curs();
How do I implement a proper loop?
Database Version : 9.0 Table stores with columns id,name