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
相关文章
- 学习使用的PL/0编译器增强版PL/0plusplusCompiler(七)扩展repeat-until
- Delphi语法中的循环WHILE..DO和REPEAT..UNTIL
- Lua中的repeat...until循环语句使用教程
- 详解Lua中repeat...until循环语句的使用方法
- 详解MySQL中concat, concat_ws, group_concat, repeat等连接字符串函数的用法
- mysql存储过程之循环语句(WHILE,REPEAT和LOOP)用法分析
- mysql向表中某字段前后追加一段字符串 concat(), trim(), ltrim(), rtrim(), repeat()
- MySQL-procedure(loop,repeat)
- MySQL 存储过程例子,不能在if else里面用begin end否则会报错Error Code : 1064!
- MySQL错误代码:END END附近的1064存储过程语法错误