postgresql 游标简单例子
来源:互联网 发布:淘宝联盟一直不提现 编辑:程序博客网 时间:2024/06/09 14:31
CREATE OR REPLACE FUNCTION cursor_demo()
RETURNS refcursor AS //返回一个游标
$BODY$
declare //定义变量及游标
unbound_refcursor refcursor; //游标
t_accid int; //变量
begin //函数开始
open unbound_refcursor for execute 'select acc_id from t_account'; //打开游标 并注入要搜索的字段的记录
loop //开始循环
fetch unbound_refcursor into t_accid; //将游标指定的值赋值给变量
if found then //任意的逻辑
raise notice '%-',t_accid;
else
exit;
end if;
end loop; //结束循环
close unbound_refcursor; //关闭游标
raise notice 'the end of msg...'; //打印消息
return unbound_refcursor; //为函数返回一个游标
exception when others then //抛出异常
raise exception 'error-----(%)',sqlerrm;//字符“%”是后面要显示的数据的占位符
end; //结束
$BODY$
RETURNS refcursor AS //返回一个游标
$BODY$
declare //定义变量及游标
unbound_refcursor refcursor; //游标
t_accid int; //变量
begin //函数开始
open unbound_refcursor for execute 'select acc_id from t_account'; //打开游标 并注入要搜索的字段的记录
loop //开始循环
fetch unbound_refcursor into t_accid; //将游标指定的值赋值给变量
if found then //任意的逻辑
raise notice '%-',t_accid;
else
exit;
end if;
end loop; //结束循环
close unbound_refcursor; //关闭游标
raise notice 'the end of msg...'; //打印消息
return unbound_refcursor; //为函数返回一个游标
exception when others then //抛出异常
raise exception 'error-----(%)',sqlerrm;//字符“%”是后面要显示的数据的占位符
end; //结束
$BODY$
LANGUAGE plpgsql; //规定语言
存储函数通过
select cursor_demo() 调用
详细请看http://blog.csdn.net/victor_ww/article/details/44240063
1 0
- postgresql 游标简单例子
- postgresql游标的简单使用
- 游标的简单例子
- 游标的简单例子
- postgresql数据库的游标使用例子说明
- sql 游标简单的例子
- 参数游标的简单例子
- SQL 游标 一个简单的例子
- pl sql游标简单例子学习
- SQL 游标 一个简单的例子
- 游标例子
- 游标例子
- 游标例子
- 游标例子
- Postgresql 游标使用
- PostgreSQL游标使用举例
- PostgreSQL游标使用举例
- PostgreSQL 游标处理
- 06
- Android 中的 WebView实现Html5视屏标签
- 用xlwings实现Call Python from Excel
- 《设计模式》 - 5. 适配器模式( Adapter )
- 利用日期正则表达式之识别合法日期
- postgresql 游标简单例子
- CoreText入门
- mysql 报错:Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65
- MonkeyKing canOpenURL: failed for URL: "weixin://" - error: "The operation couldn’t be completed. (O
- 基数排序
- S4.6_Struts2_Annotation action动作类使用annotation注解的配置方式
- webview控件介绍
- android启动页广告欢迎界面
- 一汽丰田RAV4电路图2012至2013