日期:2014-05-16 浏览次数:20892 次
create trigger amountlog_update_recalculated before update on dm_amountlog for each row BEGIN SET @cur=curdate(); set NEW.actualyear=year(@cur); set NEW.actualmonth=month(@cur); set NEW.actualday=day(@cur); SET @suma=dm_amount.paid+NEW.actualpayment; update dm_amount set dm_amount.paid=@suma where dm_amount.docid=NEW.docid; END;
create trigger amountlog_update_recalculated before update on dm_amountlog for each row BEGIN SET @cur=curdate(); set NEW.actualyear=year(@cur); set NEW.actualmonth=month(@cur); set NEW.actualday=day(@cur); SET @suma=select sum(dm_amountlog.actualpayment) from dm_amountlog where dm_amountlog.docid=NEW.docid; update dm_amount set dm_amount.paid=@suma where dm_amount.docid=NEW.docid; IF dm_amount.paid=dm_amount.payment where dm_amount.docid=NEW.docid THEN update dm_amount SET dm_amount.isdone=1 where dm_amount.docid=NEW.docid; END IF; END; $$