mysql中的光标(游标)的使用
来源:互联网 发布:凤险管理矩阵 编辑:程序博客网 时间:2024/06/06 12:41
delimiter & /*设定定界符为& */
create procedure cursor_test(in flag varchar(10),out sname_tmp varchar(10),out age_tmp tinyint )
begin
declare _sname varchar(20);/*声明局部变量*/
declare _snumber varchar(20);
declare _age tinyint ;
declare cursor_stu cursor for select snumber,age,sname from student;/*声明光标*/
declare exit handler for not found close cursor_stu;/*定义条件处理*/
open cursor_stu;/*打开光标*/
repeat
fetch cursor_stu into _snumber,_age,_sname ;/*使用光标遍历每行数据*/
if _snumber=flag then /*使用if进行判断光标中的数据*/
select _sname,_age into sname_tmp,age_tmp ;/*取出满足条件要求的光标中的数据,对输出参数sname_tmp,age_tmp 赋值 */
end if;/*结束if语句*/
until _snumber=flag end repeat;/*退出循环*/
close cursor_stu;/*关闭光标*/
end &
delimiter ;
create procedure cursor_test(in flag varchar(10),out sname_tmp varchar(10),out age_tmp tinyint )
begin
declare _sname varchar(20);/*声明局部变量*/
declare _snumber varchar(20);
declare _age tinyint ;
declare cursor_stu cursor for select snumber,age,sname from student;/*声明光标*/
declare exit handler for not found close cursor_stu;/*定义条件处理*/
open cursor_stu;/*打开光标*/
repeat
fetch cursor_stu into _snumber,_age,_sname ;/*使用光标遍历每行数据*/
if _snumber=flag then /*使用if进行判断光标中的数据*/
select _sname,_age into sname_tmp,age_tmp ;/*取出满足条件要求的光标中的数据,对输出参数sname_tmp,age_tmp 赋值 */
end if;/*结束if语句*/
until _snumber=flag end repeat;/*退出循环*/
close cursor_stu;/*关闭光标*/
end &
delimiter ;
- mysql中的光标(游标)的使用
- Cursor游标(光标)的使用
- orcle数据库游标(光标)的使用
- MySQL光标的使用
- mysql 游标的使用
- mysql 游标的使用
- mysql游标的使用
- MYSQL游标的使用
- MySQL游标的使用
- mysql游标的使用
- mysql 游标的使用
- Mysql的游标使用
- mysql游标的使用
- MySQL游标的使用
- mysql 游标的使用
- MySql游标的使用
- mysql 游标的使用
- MySql 游标的使用
- 微信公众平台如何开发
- 北京邮电大学世纪学院CSDN高校俱乐部新学期纳新工作圆满完成
- (直接存取类线性表4.1.2)UVA 602 - What Day Is It?(数组的应用---日期系统的转换)
- Struts2单选按钮标签s:radio的使用及其设置默认值
- blocks在Objective-C中是怎么工作的?
- mysql中的光标(游标)的使用
- ie6下的js调试工具companion.js
- Active Directory 常用属性
- 加州立法规范数据泄露后的通告
- java中的匿名内部类演变过程
- jQuery.extend 函数详解
- 从内存角度理解指针和数组(一)
- Eclipse自动补全快捷按钮设置
- Fast Paxos