Bonjour à tous,


J'ai un problème : je voudrais vérifier qu'un Cep de vigne se trouve bien sur un Rang (et non un Inter-Rang).

Pour cela, j'ai créé un Trigger qui annule l'insertion d'un Cep se trouvant sur un Inter-Rang. Ce Trigger devrait (normalement) afficher un message du type "Le cep ne se trouve pas sur un inter-rang".


J'ai choppé un code qui devait afficher un message d'erreur puis l'ai modifié afin que cela corresponde à mon problème : http://alain-defrance.developpez.com...re-error/#LV-C

Voici le Trigger :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
CREATE TRIGGER Rang_CepRang BEFORE INSERT ON emp_cep_rangs
FOR EACH ROW
BEGIN
	DECLARE A CONDITION FOR 0;
	DECLARE EXIT HANDLER FOR A SET @error = 'Ce Cep se trouve dans un Inter-Rang'; 
	IF (SELECT TypeRang 
		FROM emp_rang AS r, emp_cep_rang AS c
		WHERE c.IdRang = r.IdRang) <> 'Rang'
	THEN SIGNAL A;
	END IF;
END//
Le problème est que... Ca marche pas


Et maintenant, le message d'erreurs :
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'A; END IF; END' at line 9
Merci de bien vouloir m'aider