Hello I get the following error when I use the trigger below:
inser into shift
-> values<15,3, '08:00:00','14:00:00'>;
ERROR 1048 <23000>: Column 'CashierCode' can not be null
Why is that? Also, is there any better writing of the following?
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;
It seems like Column ‘CashierCode’ is defined as NOT NULL. Are you sure you have a non null value for this column?
Looks like your trigger is trying to insert a NULL value to this column. Change your table definition or provide a valid value in your trigger.