Erreur de syntaxe IF dans un Trigger
Bonjour,
J'ai une erreur de sythax 1064. Elle est apparue lorsque j'ai rajouté le IF, le trigger fonctionne bien sans le IF. Je suis sous phpmyadmin.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
| CREATE DEFINER=`root`@`localhost` TRIGGER `before_insert_product` BEFORE INSERT ON `ps_product_lang` FOR EACH ROW
BEGIN
IF (NEW.id_shop =1 AND NEW.id_lang = 1)
THEN
DECLARE a TEXT;
DECLARE b TEXT;
DECLARE c TEXT;
SET a = '<p style="text-align: justify;"><span style="font-size: large;"><span class="mcePageBreak">';
SET b = CONCAT(a,NEW.name);
SET c = '</span></span></p>';
SET NEW.description = concat(b,c);
END IF;
END |
L'erreur :
Code:
MySQL a répondu: #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 'DECLARE a TEXT; DECLARE b TEXT; DECLARE c TEXT; SET a = ' at line 4
RESOLU : Enfet il fait declarer les variables au tout début, en dehors de la structure du if. Ca marche maintenant.
Merci