MySql游标的使用
2016-03-23 13:17
531 查看
begin
declare temp_user_id int default null;
declare stop int default 0;
#声明游标
declare temp_cur cursor for select f_user_id from table_test where f_user_id=1;
#声明游标的异常处理
declare continue handler for sqlstate '02000' set stop=1;
open temp_cur;
fetch temp_cur into temp_user_id;
#判断游标是否到达最后
while stop<>1 do
#各种判断
#读取下一行的数据
fetch temp_cur into temp_user_id;
#循环结束
end while;
#关闭游标
close temp_cur;
end
declare temp_user_id int default null;
declare stop int default 0;
#声明游标
declare temp_cur cursor for select f_user_id from table_test where f_user_id=1;
#声明游标的异常处理
declare continue handler for sqlstate '02000' set stop=1;
open temp_cur;
fetch temp_cur into temp_user_id;
#判断游标是否到达最后
while stop<>1 do
#各种判断
#读取下一行的数据
fetch temp_cur into temp_user_id;
#循环结束
end while;
#关闭游标
close temp_cur;
end
相关文章推荐
- mysql事务的提交和回滚和数据引擎有关
- XAMPP打开MySql出现错误
- 简单的mysql 性能和健康程度巡检
- 理解Mysql prepare预处理语句
- 理解MySQL变量和条件
- mysql数据库巡检脚本
- MySQL的Innodb缓存相关优化
- mysql primary partition分区
- mysql中You can’t specify target table for update in FROM clause错误解决方法
- wampserver中mysql数据库的空密码怎么修改
- windows下配置非安装版的MySQL5.6
- 一千行MySQL学习笔记
- mysql之触发器
- [Mysql] find_in_set()使用注意
- mysql访问被拒绝解决 ---谷营中西软件科技园
- Mysql高并发优化
- 5.7 mysqldump 问题
- mysql 5.7.10 插入新用户
- 关于mysql使用mysqlbinlog恢复被删除的数据的问题
- MySQL批量SQL插入各种性能优化