MySQL Forums
Forum List  »  Triggers

Re: Help with a trigger to change field to a negative value
Posted by: Peter Brawley
Date: May 11, 2021 02:30PM

Is this what you mean?

drop trigger if exists transactions_ins;
delimiter go
create trigger transactions_ins before insert on transactions for each row
begin
  if new.withdraw='yes' and new.amount > 0 then
    set new.amount = -new.amount;
  end if;
end;
go
delimiter ;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: Help with a trigger to change field to a negative value
340
May 11, 2021 02:30PM


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.