标签:inf handler _id arch 存储 ber value and declare
begin
declare b int;
declare use_no varchar(10);
declare use_name varchar(400);
declare card_id varchar(400);
declare count int;
declare cur_1 cursor for
select s2.member_id,
s2.realname,
s2.card_id
from bh_member.mb_member s1,bh_member.mb_member_info s2
where s1.id = s2.member_id;
-- DECLARE CONTINUE HANDLER FOR NOT FOUND SET b=1;
SET b = 0;
-- (1) sql 赋值
select count(1) INTO count
from bh_member.mb_member s1,bh_member.mb_member_info s2
where s1.id = s2.member_id;
OPEN cur_1; -- 打开游标
REPEAT
-- 从游标中循环取值
FETCH cur_1 INTO use_no, use_name, card_id;
insert into zh_ceshi(use_no,use_name,card_id) values(use_no, use_name, card_id);
set b = b+1;
UNTIL b = count (不加分号)
END REPEAT;
close cur_1; -- 关闭游标
end
mysql 存储过程 REPEAT ... UNTIL ... END REPEAT
标签:inf handler _id arch 存储 ber value and declare
原文地址:https://www.cnblogs.com/zhuyeshen/p/12080394.html