create trigger TrainingActSignUp_tri
before insert
on trainingactsignup
for each row
begin declare tempTgidVar int;
declare deptid int;
declare rs decimal;
declare rs_cursor cursor for select tgid from tgroup where fullpath like '%,,'||deptid||',,%';
set tempTgidVar=0;
set deptid=new.entityid;
open rs_cursor;
aa: loop
fetch rs_cursor into rs;
select count(tasu.entityid) into tempTgidVar from trainingactsignup tasu where tasu.entityid = rs
and tasu.entitytype = 2 and tasu.taid = new.taid;
if(tempTgidVar = 0) then
insert into trainingactsignup set taid=new.taid,entitytype=2,entityid=rs,isautomatism=1,creatorid=new.creatorid,createtime=new.createtime;
end if;
end loop aa;
close rs_cursor;
end;
这个触发器 在表里面添加数据是 死循环了 求解决办法!
before insert
on trainingactsignup
for each row
begin declare tempTgidVar int;
declare deptid int;
declare rs decimal;
declare rs_cursor cursor for select tgid from tgroup where fullpath like '%,,'||deptid||',,%';
set tempTgidVar=0;
set deptid=new.entityid;
open rs_cursor;
aa: loop
fetch rs_cursor into rs;
select count(tasu.entityid) into tempTgidVar from trainingactsignup tasu where tasu.entityid = rs
and tasu.entitytype = 2 and tasu.taid = new.taid;
if(tempTgidVar = 0) then
insert into trainingactsignup set taid=new.taid,entitytype=2,entityid=rs,isautomatism=1,creatorid=new.creatorid,createtime=new.createtime;
end if;
end loop aa;
close rs_cursor;
end;
这个触发器 在表里面添加数据是 死循环了 求解决办法!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货