我仍然是mysql触发器的新手,所以我想对我最近遇到的问题有一些帮助。 这是我所做的触发器。
delimiter |
CREATE TRIGGER Test_001 AFTER INSERT ON reponse
FOR EACH ROW BEGIN
DECLARE nb_bonne_reponse int;
DECLARE bonne_reponse varchar(255);
DECLARE valider int;
SET valider = 0;
SET nb_bonne_reponse = (select Bonne_reponse from question where Id=New.Id_question);
IF (nb_bonne_reponse = 1)THEN
SET bonne_reponse = (select Reponse_1 from question where Id=New.Id_question);
IF (bonne_reponse = New.reponse)THEN
UPDATE groupe SET Score = Score+1 where Id=New.Id_groupe);
END IF;
ELSEIF (nb_bonne_reponse = 2)THEN
SET bonne_reponse = (select Reponse_2 from question where Id=New.Id_question);
IF (bonne_reponse = New.reponse)THEN
UPDATE groupe SET Score = Score+1 where Id=New.Id_groupe);
END IF;
ELSEIF (nb_bonne_reponse = 3)THEN
SET bonne_reponse = (select Reponse_3 from question where Id=New.Id_question);
IF (bonne_reponse = New.reponse)THEN
UPDATE groupe SET Score = Score+1 where Id=New.Id_groupe);
END IF;
ELSEIF (nb_bonne_reponse = 4)THEN
SET bonne_reponse = (select Reponse_4 from question where Id=New.Id_question);
IF (bonne_reponse = New.reponse)THEN
UPDATE groupe SET Score = Score+1 where Id=New.Id_groupe);
END IF;
END|
mysql告诉我:
');
END IF;
ELSEIF (nb_bonne_reponse = 2)THEN
SET bonne_reponse = (' at line 13.
有人知道这里阻止了什么吗? 感谢