• Почему не отрабатывает mysq trigger?

    @R4W Автор вопроса
    Правильно вот как:
    DROP TRIGGER IF EXISTS queue_log;
    DELIMITER $$
    
    CREATE TRIGGER `queue_log` AFTER insert ON `queue_log`
    FOR EACH ROW BEGIN
      CASE NEW.`event` # не `queue_log`, а именно NEW
        WHEN 'COMPLETEAGENT' THEN UPDATE calls SET calls.laststep = 'answered' WHERE calls.uniqueid = NEW.callid;
        WHEN 'COMPLETECALLER' THEN UPDATE calls SET calls.laststep = 'answered' WHERE calls.uniqueid = NEW.callid;
        WHEN 'RINGNOANSWER' THEN DELETE FROM queue_log WHERE queue_log.callid = NEW.callid;
      END CASE;
    END$$
    
    DELIMITER ;
    Ответ написан
    Комментировать