I have a database already in use on a server (MySQL Community Server 5.5.40-cll) & I'm trying to add a trigger to it but I keep getting the below error.
#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 3
I'm trying to set a trigger to make sure that end_date is not before start_date, here's what I'm currently using.
CREATE TRIGGER `Meets insert` BEFORE INSERT ON `meets`
FOR EACH ROW
IF DATEDIFF(NEW.end_date, NEW.start_date) < 0 THEN
signal sqlstate '45000' set message_text = 'start_date must be before end_date';
END IF;
I've had a look in the MySQL documentation for 5.5 and it seems like everything I'm doing is supported by this version and I'm using it correctly.
I'm sure the if statement is correct as I asked another similar question earlier here on Stack Overflow about a separate problem I was having which worked fine. Although that was on a local development database where as this is on a server.
If anyone can spot what I'm doing wrong or has an idea of what to check it will be appreciated.
Thought I'd point out the server I'm making this change on isn't a production one.