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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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 ;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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.
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 ;
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'