I'm working on the final for my DBA class and I have to create a trigger that will check to see if the date_added field is NULL and change it to the current date if it is. Unfortunately, it keeps giving me an error.
Trigger:
DELIMITER //
CREATE TRIGGER products_before_insert
BEFORE INSERT ON products FOR EACH ROW
BEGIN
IF date_added IS NULL THEN
SET NEW.date_added = GETDATE();
END //
DELIMITER ;
I use FileZilla to upload this .sql file to the server, then source it through putty. But whenever I try to source it, I get this error.
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 '' at line 6
I have tried several other methods, but none seem to work. I'm not sure what the problem is and would greatly appreciate any help.