DROP TRIGGER IF EXISTS before_delete_concept_access;
DELIMITER //
CREATE TRIGGER before_delete_concept_access
BEFORE DELETE ON `concept_access` FOR EACH ROW
BEGIN
IF (SELECT COUNT(*) FROM concept_access_log WHERE map=OLD.map
AND accesstype=OLD.accesstype AND startdate=OLD.startdate AND stopdate=OLD.stopdate) = 0 THEN
INSERT INTO concept_access_log (map, accesstype, startdate, stopdate)
VALUES (OLD.map, OLD.accesstype, OLD.startdate, OLD.stopdate);
END IF;
END//
DELIMITER ;
Je n'utilise pas not exists
, testez simplement si le nombre de correspondances est supérieur à 0
votre code fonctionne bien sur ma machine, quelle est votre version de MySQL ?
mysql> select version();
+------------+
| version() |
+------------+
| 5.1.56-log |
+------------+
1 row in set (0.00 sec)