MySQL Forums
Forum List  »  Triggers

Re: Error creating Trigger
Posted by: Jassim Rahma
Date: July 25, 2019 12:12PM

Thanks Peter..

I have another problem please..


22:10:13 CREATE TRIGGER trigger_monitor AFTER INSERT ON monitor FOR EACH ROW BEGIN UPDATE hosts SET average_time = (SELECT AVG(roundtrip_time) FROM monitor WHERE host_id = NEW.host_id), maximum_time = (SELECT MAX(roundtrip_time) FROM monitor WHERE host_id = NEW.host_id), minimum_time = (SELECT MIN(roundtrip_time) FROM monitor WHERE host_id = NEW.host_id) WHERE host_id = NEW.host_id Error Code: 1064. 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 '' at line 9 0.016 sec




Here is the updated trigger:

USE maxmon;

CREATE TRIGGER trigger_monitor
AFTER INSERT
ON monitor FOR EACH ROW
BEGIN
UPDATE hosts
SET average_time = (SELECT AVG(roundtrip_time) FROM monitor WHERE host_id = NEW.host_id),
maximum_time = (SELECT MAX(roundtrip_time) FROM monitor WHERE host_id = NEW.host_id),
minimum_time = (SELECT MIN(roundtrip_time) FROM monitor WHERE host_id = NEW.host_id)
WHERE host_id = NEW.host_id;

END;

Options: ReplyQuote


Subject
Views
Written By
Posted
1922
July 24, 2019 08:57AM
696
July 24, 2019 04:21PM
Re: Error creating Trigger
748
July 25, 2019 12:12PM
650
July 25, 2019 12:15PM
658
July 25, 2019 12:26PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.