写了一个存储过程,代码如下,作用是将模块表和用户表中的模块id和用户id都查询出来,然后逐一匹配写入user_module表中,但是执行结果确实,只写入了一个用户的数据,其他的用户都没有,这是什么情况呢?
create procedure in_do()
begin
declare moid,puid int;
declare do1,do2 int default false;
declare attr_1 cursor for select id from user_public;
declare attr_2 cursor for select id from public_module where status='1' and (pid!=0 or special='1');
declare continue handler for not found set do1=true;
open attr_1;
read_loop:loop
fetch attr_1 into puid;
if do1 then
leave read_loop;
end if;
begin
declare continue handler for not found set do2=true;
open attr_2;
read_loop1:loop
fetch attr_2 into moid;
if do2 then
leave read_loop1;
end if;
insert into user_module(public_id,module_id,stime,etime) values(puid,moid,'1483203661','1514739661');
end loop;
close attr_2;
end;
end loop;
close attr_1;
end //