TYPE=TRIGGERS
triggers='CREATE DEFINER=`root`@`localhost` TRIGGER `DetRetBeliAdd` AFTER INSERT ON `tr_retbeli_d` FOR EACH ROW BEGIN\ndeclare vnoretb varchar(11);\nDECLARE vjumlah  double; \nDECLARE vTglBatal datetime;\nDeclare vnobeli varchar(11);\ndeclare vcode varchar(20);\ndeclare vitemBeli int;\ndeclare vtrans varchar(2);\ndeclare vTransbeli varchar(2);\ndeclare vKodeGd varchar(5);\n select TransRetB,NoretB,Kodebrg, ifnull(jml,0),kodegd, ifnull(TransBeli,\'\'), ifnull(NoBeli,\'\'), ifnull(itemBeli,0) into vtrans,vNoretB,vcode,vjumlah,vkodegd, vTransbeli, vNoBeli, vItemBeli \n from Tr_RetBeli_d where TransRetB = new.TransRetB and NoretB = new.NoretB and ItemRetB=new.ItemretB;\n select Tglbatal into vTglbatal from Tr_RetBeli_M where new.TransRetB and NoretB = new.NoretB;\n update tm_stockbrg set stockakhir = ifnull(stockakhir,0) -new.jml where kodebrg=new.kodebrg and kodeGd= new.KodeGD; \n \n if (vnobeli<>\'\') and (vTransBeli<>\'\') and (vItemBeli<>0) then\n    update Tr_Beli_d set diretur = ifnull(diretur,0) + vJumlah where Transbeli=vTransBeli and nobeli=vnobeli and ItemBeli=vItemBeli;\n end if;\nend' 'CREATE DEFINER=`root`@`localhost` TRIGGER `DetRetBeliUpdate` AFTER UPDATE ON `tr_retbeli_d` FOR EACH ROW BEGIN\n declare vnoretb varchar(11);\n DECLARE vjumlah  double; \n DECLARE vTglBatal datetime;\n Declare vnobeli varchar(11);\n declare vcode varchar(20);\n declare vitemBeli int;\n declare vtrans varchar(2);\n declare vTransbeli varchar(2);\n declare vKodeGd varchar(5);\n  select TransRetB,NoretB,Kodebrg, ifnull(jml,0),kodegd, ifnull(TransBeli,\'\'), ifnull(NoBeli,\'\'), ifnull(itemBeli,0) into vtrans,vNoretB,vcode,vjumlah,vkodegd, vTransbeli, vNoBeli, vItemBeli \n  from Tr_RetBeli_d where TransRetB = new.TransRetB and NoretB = new.NoretB and ItemRetB=new.ItemretB;\n  select Tglbatal into vTglbatal from Tr_RetBeli_M where new.TransRetB and NoretB = new.NoretB;\n  update tm_stockbrg set stockakhir = ifnull(stockakhir,0) +Old.jml where kodebrg=Old.kodebrg and kodeGd= Old.KodeGD; \n  update tm_stockbrg set stockakhir = ifnull(stockakhir,0) -new.jml where kodebrg=new.kodebrg and kodeGd= new.KodeGD; \n  update tr_Beli_d set diretur = ifnull(diretur,0)-Old.Jml  where Transbeli=old.TransBeli and nobeli=old.nobeli and ItemBeli=old.ItemBeli;\n  update tr_Beli_d set diretur = ifnull(diretur,0)+New.Jml  where Transbeli=new.TransBeli and nobeli=new.nobeli and ItemBeli=new.ItemBeli;\nend' 'CREATE DEFINER=`root`@`localhost` TRIGGER `DetRetBeliDelete` AFTER DELETE ON `tr_retbeli_d` FOR EACH ROW BEGIN\nif ifNull(Old.locked,\'N\')<>\'Y\' then\n update tm_stockbrg set stockakhir = ifnull(stockakhir,0) +Old.jml where kodebrg=Old.kodebrg and kodeGd= Old.KodeGD; \nend if;\nif ifNull(Old.locked,\'N\')=\'Y\' then\n update tm_stockbrg set stockakhir = ifnull(stockakhir,0) +Old.sisa where kodebrg=Old.kodebrg and kodeGd= Old.KodeGD; \nend if;\n update tr_Beli_d set diretur = ifnull(diretur,0)-Old.Jml  where Transbeli=old.TransBeli and nobeli=old.nobeli and ItemBeli=old.ItemBeli;\nend'
sql_modes=524288 524288 524288
definers='root@localhost' 'root@localhost' 'root@localhost'
