Menu

Help w/ MYSQL

Help
MKW
2012-04-06
2015-11-11
  • MKW

    MKW - 2012-04-06

    I've read the other notes on the subject, but they're not helping.  I still can't get the triggers to work.  Here's what Iget:

    mysql> create trigger chu after update on nagios_hoststatus
        -> for each row begin
        -> replace into events.e select new.host_object_id, now();
    ERROR 1064 (42000): 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 'replace into events.e select new.host_object_id, now()' at line 3

    I've tried the delimiter trick, but that ended up not creating the triggers.  Any ideas? I'm using mysql 5.1.

     
  • Juan

    Juan - 2014-09-25

    Hello MKW try this

    DELIMITER //
    CREATE TRIGGER hup AFTER UPDATE ON nagios_hoststatus FOR EACH ROW BEGIN
    IF NEW.current_state > 0 THEN
    REPLACE INTO events.e SELECT NEW.host_object_id, NEW.host_object_id, now();
    ELSEIF OLD.current_state > 0 THEN
    DELETE FROM events.e WHERE NEW.host_object_id = object_id;
    END IF;
    END;//
    DELIMITER ;

     
  • Robert

    Robert - 2015-11-11

    I'm getting the same error that MKW is. I tried your solution and I'm getting this:

    This version of MySQL doesn't yet support 'multiple triggers with the same action time and event for one table'

     

Log in to post a comment.