0
votes

delimiter // drop trigger if exists tr_overdue //

create trigger tr_overdue -- type of trigger, etc
after update on invoice for each row begin if status = 'overdue' then insert into alerts values(new.message_date,new.origin,new.message); SET action = 'update', message_date = NOW(), origin=old.campaignno, message = 'invoice with number ' + old.invoiceno + ' is now overdue'; end if; end

1

1 Answers

0
votes
CREATE TRIGGER tr_overdue AFTER UPDATE ON Invoice FOR EACH ROW IF STATUS = 'overdue' THEN INSERT INTO alerts(columns1, column2,...) VALUES(new.message_date,new.origin,new.message);

I'm unsure if the columns you're updating in the SET statement also belong in Invoice, but if they do, then they should be included into the INSERT statement and that should fix the problem.