Possible Duplicate:
MySQL Trigger to prevent INSERT under certain conditions
In MySQL BEFORE INSERT TRIGGER
how can I skip data insertion under condition?
delimiter //
drop trigger if exists test_trigger //
create trigger test_trigger before insert on t
for each row
begin
set @found := false;
#Some code
if @found then
#How to skip the data insertion under condition?
end if;
end //
delimiter ;
Two solutions, both raise an error:
CALL non_existent_proc()
Example 1:
...
IF @found THEN
CALL non_existent_proc();
END IF;
...
Example 2:
...
IF @found THEN
SIGNAL SQLSTATE '02000' SET MESSAGE_TEXT = 'Wrong data';`
END IF;
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With