J'ai deux tables :
sanction
avec ces attributs :DriverID
,Calification
,Points
people
avec ces attributs :pID
,city
,TotalPoints
Et j'ai ce déclencheur :
DROP TRIGGER IF EXISTS updatePoints_tgr;
delimiter $$
CREATE TRIGGER
updatePoints_tgr AFTER UPDATE
ON sanctions FOR EACH ROW
BEGIN
if NEW.points > OLD.points
THEN
UPDATE people
SET TotalPoints = TotalPoints + (NEW.points - OLD.points)
WHERE people.pID = NEW.DriverID;
elseif NEW.points < OLD.points
THEN
UPDATE people
SET TotalPoints = TotalPoints - (NEW.points - OLD.points)
WHERE people.pID = NEW.DriverID;
END IF;
END$$
delimiter ;
Et quand j'essaie d'exécuter cette mise à jour
UPDATE sanctions
JOIN people ON sanctions.DriverID=people.pID
SET points=points+6
WHERE city='Barcelona' AND Calification='LightPenalty'
Je reçois cette erreur :
Impossible de mettre à jour la table 'people' dans une fonction/déclencheur stocké car elle est déjà utilisée par l'instruction qui a invoqué cette fonction/déclencheur.
Comment puis-je le réparer ? Merci.
J'utilise Windows 10 et le serveur MySQL 5.7.17