MySQL Trigger Help Please

Soldato
Joined
26 Aug 2012
Posts
4,399
Location
North West
I am trying to create an application that allows users to create rules to generate alerts based on log values going into the Database.

The trigger created fine and is as follows:
Code:
CREATE TRIGGER `test_rule` AFTER INSERT ON `log_application`
 FOR EACH ROW BEGIN
IF NEW.application_name LIKE chrome THEN 
INSERT INTO log_alerts (alert_message) VALUES ('Chrome Installed');
END IF;
END

This rule is meant to generate an alert message if a row with an application_name containing 'chrome' is inserted into the 'log_application' table.

However, every time i try to insert a row to test it works I get the following DB Error:
OqnKgkM.png

I know it is being able to match the word 'chrome' as if I insert an application name not containing 'chrome' there is no DB error caused by the trigger, so I know the issue is with the trigger, even though the error suggests otherwise.

Any help would be more appreciated.
 
Last edited:
Associate
Joined
12 Jun 2005
Posts
239
My SQL isnt too strong, but there may be an issue with the use of the LIKE operator.

Could you try:

IF NEW.application_name LIKE '%chrome%' THEN
 
Back
Top Bottom