Bonjour,

Le trigger :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
CREATE TRIGGER del_pers BEFORE INSERT
ON routage_pers_tmp
FOR EACH ROW
BEGIN
IF ((SELECT COUNT(A.NUM_CARTE) FROM adherent A WHERE A.NUM_CARTE=NEW.NUM_CARTE)=0)
THEN
INSERT INTO routage_pers_tmp SELECT NEW.*;
END IF;
END;
Si le NUM_CARTE de la ligne qu'on tente d'insérer dans routage_pers_tmp n'est pas dans la table adherent, on l'insère.

Le trigger se crée correctement.

Mais lors de l'exécution :


==> erreur mysql :
Can't update table 'routage_pers_tmp1' in stored function/trigger because it is already used by statement which invoked this stored function/trigger.
2ème tentative :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
CREATE TRIGGER del_pers BEFORE INSERT
ON routage_pers_tmp1
FOR EACH ROW
BEGIN
IF ((SELECT COUNT(A.NUM_CARTE) FROM adherent A WHERE A.NUM_CARTE=NEW.NUM_CARTE)=0)
THEN
INSERT INTO routage_pers_tmp2 SELECT NEW.* FROM routage_pers_tmp1;
END IF;
END;
==> UNknown table NEW.

Merci de votre aide ...