如何在触发器中使用if 判断
创建名字为 ins_staffRoom 的触发器 ,判断 flag 状态进行处理
CREATE TRIGGER ins_staffRoom AFTER INSERT ON tb_staff_room FOR EACH ROW begin
if new.flag = ‘0’ and ‘0’= (select issue_mode
from tb_village where new.villageid = id )
then
insert into tb_log_staff (id,staffid, org_code,imgpath,type)
values( new.id, new.staffid,new.org_code,new.imgpath,‘0’);
end if;
if new.flag = ‘1’ and ‘1’= (select issue_mode
from tb_village where new.villageid = id )
then
insert into tb_log_staff (id,staffid, org_code,imgpath,type)
values( new.id, new.staffid,new.org_code,new.imgpath,‘1’);
end if;
end;