Wednesday, 15 April 2015

MYSql after update trigger not updating table -



MYSql after update trigger not updating table -

i have next trigger:

create definer = current_user trigger `radia`.`orderstable_after_update` update on `orderstable` each row begin set @vatcharged = amount * (vat*0.01);

but vatcharged column not update after there alter amount or vat.

the table has next columns; order number(int), accno(varchar), invoice number(varchar), description(varchar), amount(int), vat(int) , vatcharged(int).

what solution problem?

you need specify old or new against column either old value before update or new value after update

set @vatcharged := new.amount * (new.vat*0.01);

edit : if want update vatcharged column in table, trigger needs before update as

delimiter // create trigger `radia`.`orderstable_after_update` before update on `orderstable` each row begin set new.vatcharged = new.amount * (new.vat*0.01); end ; // delimiter ;

mysql

No comments:

Post a Comment