Reputation: 623
With the following sql code:
CREATE TRIGGER yirmi_test BEFORE UPDATE ON `orders`
FOR EACH ROW
IF ((OLD.`product_price_currency` != "") AND (NEW.`product_price_currency` = "")) THEN
signal sqlstate '45000' set message_text = 'Erasing currency';
END IF;
I get the following 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 4
Upvotes: 0
Views: 33
Reputation: 24959
I think you are fine. Just wrap with the following begin and end delimiter
block. It passed a 1064 test for me:
DELIMITER $$
CREATE TRIGGER yirmi_test BEFORE UPDATE ON `orders`
FOR EACH ROW
IF ((OLD.`product_price_currency` != "") AND (NEW.`product_price_currency` = "")) THEN
signal sqlstate '45000' set message_text = 'Erasing currency';
END IF;
$$
DELIMITER ;
Read the bottom of This concerning delimiters. It is trivial, but it can waste hours.
Upvotes: 1