游标,句柄操作数处理异常
作者:互联网
create PROCEDURE proc12_cursor_handler(in p_sid int)
begin
DECLARE v_name varchar(20);
DECLARE v_gender varchar(10);
DECLARE v_age int;
declare flag int DEFAULT 1;
DECLARE c_mycursor cursor for
select name,gender,age from student where sid=p_sid;//定义游标
declare CONTINUE HANDLER for 1329 set flag=0;//定义异常句柄‘1329’
open c_mycursor;//打开游标
lab:loop
FETCH c_mycursor into v_name,v_gender,v_age;//循环读取数据
if flag=1 then
select v_name,v_gender,v_age;
else
leave lab;
end if;
end loop;
close c_mycursor;//关闭游标
end
call proc12_cursor_handler(1001)
标签:操作数,name,句柄,age,游标,mycursor,gender,DECLARE 来源: https://www.cnblogs.com/dlldll/p/16076413.html