TYPE=TRIGGERS
triggers='CREATE DEFINER=`root`@`localhost` TRIGGER `ScrBayarBeliAdd` AFTER INSERT ON `tr_scrbayarbeli` FOR EACH ROW BEGIN\ndeclare vTransbeli varchar (2);\nDECLARE vNoBeli varchar (11);\nDECLARE vNilai double; \nDECLARE vTglBatal datetime;\nDeclare vKodeSupp varchar(10);\ndeclare vNoBayar varchar(11);\ndeclare vExrate integer;\nselect ifnull(TransBeli,\'\'), ifnull(NoBeli,\'\'), ifnull(Nilai,0), ifnull(ExRate,1) into  vTransbeli, vNoBeli, vNilai ,vexrate \nfrom Tr_ScrBayarBeli where NoBayarB = new.NobayarB and ItemSBayarB=new.ItemSBayarB;\nselect Tglbatal,KodeSupp into vTglbatal,vKodeSupp from tr_BayarBeli_M where NoBayarB=new.NoBayarB;\nif ifnull(vTglBatal,\'\')=\'\' then\n update tr_beli_m set Sisa=ifnull(Sisa,0)-new.Nilai where NoBeli=vNoBeli and TransBeli=vTransBeli;\n update tM_Supplier set hutang= ifnull(Hutang,0)-new.Nilai*new.ExRate where KodeSupp=vKodeSupp;\nEND if;\nend' 'CREATE DEFINER=`root`@`localhost` TRIGGER `ScrBayarBeliUpdate` AFTER UPDATE ON `tr_scrbayarbeli` FOR EACH ROW BEGIN\ndeclare vTransBelibaru varchar(2);\nDECLARE vNoBeliBaru varchar(11);\nDECLARE vNilaiBaru double; \nDECLARE vTglBatal datetime;\nDeclare vKodeSupp varchar(10);\ndeclare vNoBayar varchar(11);\ndeclare vExrateBaru integer;\ndeclare vExrateLama integer;\ndeclare vTransBelilama varchar(2);\ndeclare vNoBeliLama varchar(11);\nDECLARE vNilaiLama double; \nselect ifnull(TransBeli,\'\'), ifnull(NoBeli,\'\'), ifnull(Nilai,0), ifnull(ExRate,1) into  vTransbeliBaru, vNoBeliBaru, vNilaiBaru ,vexrateBaru \nfrom Tr_ScrBayarBeli where NoBayarB = new.NobayarB and ItemSBayarB=new.ItemSBayarB;\nselect Tglbatal,KodeSupp into vTglbatal,vKodeSupp from tr_BayarBeli_M where NoBayarB=new.NoBayarB;\nif ifnull(vTglBatal,\'\')=\'\' then\n update tr_beli_m set Sisa=ifnull(Sisa,0)+Old.Nilai where NoBeli=Old.NoBeli and TransBeli=Old.TransBeli;\n update tr_beli_m set Sisa=ifnull(Sisa,0)-New.Nilai where NoBeli=New.NoBeli and TransBeli=New.TransBeli;\n update tM_Supplier set hutang= ifnull(Hutang,0)+(Old.Nilai*Old.ExRate ) where KodeSupp=vKodeSupp;\n update tM_Supplier set hutang= ifnull(Hutang,0)-(New.Nilai*New.ExRate) where KodeSupp=vKodeSupp;\nEND if;\nend' 'CREATE DEFINER=`root`@`localhost` TRIGGER `ScrBayarBeliDelete` AFTER DELETE ON `tr_scrbayarbeli` FOR EACH ROW BEGIN\ndeclare vTransBelibaru varchar(2);\nDECLARE vNoBeliBaru varchar(11);\nDECLARE vNilaiBaru double; \nDECLARE vTglBatal datetime;\nDeclare vKodeSupp varchar(10);\ndeclare vNoBayar varchar(11);\ndeclare vExrateBaru integer;\ndeclare vExrateLama integer;\ndeclare vTransBelilama varchar(2);\ndeclare vNoBeliLama varchar(11);\nDECLARE vNilaiLama double; \nselect ifnull(TransBeli,\'\'), ifnull(NoBeli,\'\'), ifnull(Nilai,0), ifnull(ExRate,1) into  vTransbeliBaru, vNoBeliBaru, vNilaiBaru ,vexrateBaru \nfrom Tr_ScrBayarBeli where NoBayarB = Old.NobayarB and ItemSBayarB=old.ItemSBayarB;\nselect Tglbatal,KodeSupp into vTglbatal,vKodeSupp from tr_BayarBeli_M where NoBayarB=Old.NoBayarB;\nif ifnull(vTglBatal,\'\')=\'\' then\n update tr_beli_m set Sisa=ifnull(Sisa,0)+Old.Nilai  where NoBeli=Old.NoBeli and TransBeli=Old.TransBeli;\n update tM_Supplier set hutang= ifnull(Hutang,0)+(Old.Nilai*Old.ExRate)  where KodeSupp=vKodeSupp;\nEND if;\nend'
sql_modes=524288 524288 524288
definers='root@localhost' 'root@localhost' 'root@localhost'
