我在插入之前在表上成功触发了触发器,但是在触发触发器后数据没有插入到表中
CREATE TRIGGER `limit_refferals` BEFORE INSERT ON `wpmr_aff_referrals`
FOR EACH ROW BEGIN
DECLARE vCNT INT;
DECLARE USERID varchar(50);
DECLARE AFFILIATEID varchar(50) default NEW.affiliate_id;
DECLARE USER_AFFID varchar(50);
DECLARE i INTEGER;
DECLARE curs1 CURSOR FOR
SELECT USER_ID,affiliate_id
FROM `wpmr_aff_referrals` WHERE affiliate_id=AFFILIATEID;
SELECT CUSTOMERLEVEL(AFFILIATEID) INTO vCNT;
IF (vCNT >=3) THEN
while (AFFILIATEID is not null) do
OPEN curs1;
read_loop : LOOP
FETCH curs1 INTO USERID,AFFILIATEID;
SELECT CUSTOMERLEVEL(AFFILIATEID) INTO vCNT;
SELECT affiliate_id INTO USER_AFFID FROM wpmr_aff_affiliates_users WHERE USER_ID=USERID;
IF (vCNT>=3) THEN
set AFFILIATEID=USER_AFFID;
ELSE
set new.affiliate_id := USER_AFFID;
set AFFILIATEID=null;
END IF;
END LOOP read_loop;
CLOSE curs1;
END WHILE;
END IF;
END