Reputation: 125
I want to create a BEFORE CREATE TRIGGER that checks if some restrictions apply, and if they don't, it stops the row from being added. I know i can access specific values of the added item with the NEW keyword, but how can i command mysql to suppress the insertion?
Upvotes: 0
Views: 56
Reputation: 8101
Inside your trigger You can stop your insert using SIGNAL keyword as below
if(<your condition>) then
SIGNAL SQLSTATE '45000' SET MESSAGE_TEXT = 'your error message';
end if
This will stop inserting
Upvotes: 2