/ 中存储网

MySQL服务器存储过程中使用游标的方法

2014-07-13 16:37:33 来源:中存储网
create procedure getInfor2()
BEGIN
declare _abc varchar(200);
declare stopFlag int;
DECLARE cursor_name CURSOR
FOR
select zhuanyuan from server;
DECLARE CONTINUE HANDLER FOR NOT FOUND set stopFlag=1;
OPEN cursor_name;
REPEAT
FETCH cursor_name INTO _abc;
begin
if _abc='root'
then
insert t(s1) values(3333);
end if;
end;
UNTIL stopFlag = 1
END REPEAT;
CLOSE cursor_name;
END;