0

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

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.