How do I do the equivalent statement in MySQL? I want it if input is a certain value, don’t insert the row. In SQL SERVER, I can just say ROLLBACK. What’s the equivalent command in MySQL? Thank you.
CREATE TRIGGER tr_some_trigger
ON some_table
FOR INSERT
AS
BEGIN
IF inserted.topic == 'test' THEN
ROLLBACK
ENDIF
END
From this document:
So
ROLLBACKwon’t work inside your trigger, but if the trigger raises an exception/error, it will prevent the insertion to succeed, so what you can do is raise an exception if your condition is met (one way is to call an undefined function).For example:
Assuming func_1 doesn’t exist it will prevent your new record of being inserted.