【发布时间】:2011-06-20 15:11:21
【问题描述】:
您好,当我使用下面的触发器时出现以下错误:
inser into shift
-> values<15,3, '08:00:00','14:00:00'>;
ERROR 1048 <23000>: Column 'CashierCode' can not be null
这是为什么呢?还有,下面有没有更好的写法?
DELIMITER @
create trigger shist_start
before insert on shift
for each row
begin
if(new.CashierCode not in(
select w.EmployeeCode from WorksOn as w
join shop as s on w.ShopCode = s.ShopCode
join CashMachine as c on s.ShopCode = c.ShopCode
where c.CashMachineID=new.CashMachineID ))
then set new.CashierCode = NULL;
end if;
end;
【问题讨论】:
-
旁注:应该是
new.CashierCode,而不是new, CashierCode。是不是印错了? -
谢谢,是的,我打错了