Questa è la mia dichiarazione mysql grillettoMysql errore per l'utilizzo di delimitatori in trigger
DELIMITER |
CREATE TRIGGER kk AFTER UPDATE
ON location FOR EACH ROW
BEGIN
IF NEW.name not in(SELECT A.name FROM filter A WHERE (NEW.name = A.name))THEN
IF NEW.location_name != OLD.location_name THEN
INSERT INTO filter(old_location_name,new_location_name)
VALUES (OLD.location_name, NEW.location_name);
ELSE
UPDATE filter SET old_location_name = OLD.location_name , new_location_name = NEW.location_name WHERE name = OLD.name;
END IF;
ELSE
UPDATE filter SET old_location_name = OLD.location_name , new_location_name = NEW.location_name WHERE name = OLD.name;
END IF;
END;|
DELIMITER ;
Questo funziona bene, quando ho incolla questo codice in phpMyAdmin.
E nel mio progetto
$sqlDrop = "DROP TRIGGER IF EXISTS `kk`";
$resDrop = parent::_executeQuery($sqlDrop);
echo $sql = "same above delimiter trigger query";
$rs = parent::_executeQuery($sql);
Ora i $sql
echi economico in un unico linea
DELIMITER | CREATE TRIGGER kk AFTER UPDATE ON location FOR EACH ROW BEGIN IF NEW.name not in(SELECT A.name FROM filter A WHERE (NEW.name = A.name))THEN IF NEW.location_name != OLD.location_name THEN INSERT INTO filter(old_location_name,new_location_name,name) VALUES (OLD.location_name, NEW.location_name); ELSE UPDATE filter SET old_location_name = OLD.location_name , new_location_name = NEW.location_name WHERE name = OLD.name; END IF; ELSE UPDATE filter SET old_location_name = OLD.location_name , new_location_name = NEW.location_name WHERE name = OLD.name; END IF; END;| DELIMITER ;
e la query non viene eseguito. E quando ho incollare l'istruzione eco nel mio phpMyAdmin, its me mostrando un errore
Quindi, quello che potrebbe essere il problema. È il modo giusto per eseguire query di trigger?
Grazie a questo ha funzionato bene ... evviva – Matarishvan