delimiter //
create trigger tr_emp2 before insert or update
on employee for each row
begin
if new.ID<>10100 then
if new.Mgr not in (select ID from employee)
then
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'Invalid Mgr_id!';
end if;
end if;
end;//
delimiter ;
如何表达“在插入或更新之前创建触发器tr_emp”,是否是错误的外向访问?
最佳答案
您必须创建两个触发器,但您可以将公共(public)代码移至过程中并让它们都调用该过程。
关于MySQL "create trigger tr_emp before insert or update",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47311631/