0
我想通过游标(plpgsql)结果循环,但不知何故在输出控制台上没有打印任何东西。循环游标结果
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();
如何实现一个合适的循环?
数据库版本:9.0 表店的列ID,名称
这个问题也应该提供表格定义和你的Postgres版本。 –
@ErwinBrandstetter更新了问题 – Pradeep
但这不是表格定义。表定义是一个完整的'CREATE TABLE'脚本,显示数据类型和约束,或者你在psql中使用'\ d tbl'获得的内容。 –