MySQL Forums
Forum List  »  Triggers

Re: Create a trigger that prevents updating all rows in a table
Posted by: Peter Brawley
Date: August 29, 2017 01:08PM

> there is a bug that sets the 'sent_at' column to today's date for all the rows

A bug in what software? It can't be fixed?

This might solve your problem ...

drop trigger if exists emails_upd;
delimiter go
create trigger emails_upd before update on emails for each row
begin
  if new.date = curdate() and old.date < curdate() then
    set new.date = old.date;
  end if;
end;
go
delimiter ;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Create a trigger that prevents updating all rows in a table
752
August 29, 2017 01:08PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.