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'獲得的內容。 –