TYPE=TRIGGERS
triggers='CREATE DEFINER=`root`@`localhost` TRIGGER `BeforeAdd_DetJual` BEFORE INSERT ON `tr_jual_d` FOR EACH ROW BEGIN\n  DECLARE vSatuan VARCHAR(255);\n DECLARE vSatuan1 VARCHAR(255);\n DECLARE vSatuan2 VARCHAR(255);\n   DECLARE vSatuan3 VARCHAR(255);\n  DECLARE vKonv1 DOUBLE;\n  DECLARE vKonv2 DOUBLE;\n  DECLARE vKonv3 DOUBLE;\n select satuan,satuan1,satuan2,satuan3,konv1,konv2,konv3 into vSatuan,vSatuan1,vSatuan2,vSatuan3,vKonv1,vKonv2,vKonv3 from tm_barang where kodebrg=new.kodebrg;\nif new.satuan = vSatuan then\n   set new.konv=1;\nend if;\nif new.satuan = vSatuan1 then\n  set new.konv=vKonv1;\nend if;\nif new.satuan =vSatuan2 then\n  set new.konv=vKonv2;\nend if;\nif new.satuan = vSatuan3 then\n  set new.konv = vKonv3;\nend if;\nEND' 'CREATE DEFINER=`root`@`localhost` TRIGGER `DetJualAdd` AFTER INSERT ON `tr_jual_d` FOR EACH ROW BEGIN\n DECLARE vtemp double;\n    Update tm_stockbrg set Stockakhir =  stockakhir-(new.jml*ifnull(new.konv,0)) where kodebrg=new.kodebrg and kodeGd= new.KodeGD;\nend' 'CREATE DEFINER=`root`@`localhost` TRIGGER `BeforeUpd_DetJual` BEFORE UPDATE ON `tr_jual_d` FOR EACH ROW BEGIN\n  DECLARE vSatuan VARCHAR(255);\n DECLARE vSatuan1 VARCHAR(255);\n DECLARE vSatuan2 VARCHAR(255);\n   DECLARE vSatuan3 VARCHAR(255);\n  DECLARE vKonv1 DOUBLE;\n  DECLARE vKonv2 DOUBLE;\n  DECLARE vKonv3 DOUBLE;\n select satuan,satuan1,satuan2,satuan3,konv1,konv2,konv3 into vSatuan,vSatuan1,vSatuan2,vSatuan3,vKonv1,vKonv2,vKonv3 from tm_barang where kodebrg=new.kodebrg;\nif new.satuan = vSatuan then\n   set new.konv=1;\nend if;\nif new.satuan = vSatuan1 then\n  set new.konv=vKonv1;\nend if;\nif new.satuan =vSatuan2 then\n  set new.konv=vKonv2;\nend if;\nif new.satuan = vSatuan3 then\n  set new.konv = vKonv3;\nend if;\nEND' 'CREATE DEFINER=`root`@`localhost` TRIGGER `DetJualUpdate` AFTER UPDATE ON `tr_jual_d` FOR EACH ROW BEGIN\n  Update tm_stockbrg set Stockakhir =  stockakhir+(new.jml*ifnull(new.konv,0)) where kodebrg=new.kodebrg and kodeGd= new.KodeGD;\n  Update tm_stockbrg set Stockakhir =  stockakhir-(old.jml*ifnull(old.konv,0)) where kodebrg=old.kodebrg and kodeGd= old.KodeGD;\nend' 'CREATE DEFINER=`root`@`localhost` TRIGGER `DetJualDelete` AFTER DELETE ON `tr_jual_d` FOR EACH ROW BEGIN\n  Update tm_stockbrg set Stockakhir =  stockakhir+(old.jml*ifnull(old.konv,0))\n  where kodebrg=Old.kodebrg and kodeGd= Old.KodeGD;\nend'
sql_modes=524288 524288 524288 524288 524288
definers='root@localhost' 'root@localhost' 'root@localhost' 'root@localhost' 'root@localhost'
