TYPE=TRIGGERS
triggers='CREATE DEFINER=`root`@`localhost` TRIGGER `SaldoAwalAdd` AFTER INSERT ON `tb_saldoawal` FOR EACH ROW BEGIN\nDeclare vtemp double;\n  select count(*) into vtemp from tm_stockbrg where kodebrg=new.kodebrg and kodeGd= new.KodeGD;\n  if vtemp = 0 then\n     insert  into tm_stockbrg (kodebrg,namabrg,kodegd,StockAwal,stockakhir) values (new.kodebrg,new.namabrg,new.kodegd,new.saldoawal*new.konv,new.saldoawal*new.konv);\n  else\n     Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)+new.saldoawal*new.konv where kodebrg=new.kodebrg and kodeGd= new.KodeGD;\n  END if;\nend' 'CREATE DEFINER=`root`@`localhost` TRIGGER `SaldoAwalUpdate` AFTER UPDATE ON `tb_saldoawal` FOR EACH ROW BEGIN\ndeclare vtemp double;\n  select count(*) into vtemp from tm_stockbrg where kodebrg=new.kodebrg and kodeGd= new.KodeGD;\n  if vtemp = 0 then\n     insert  into tm_stockbrg (kodebrg,namabrg,kodegd,StockAwal,stockakhir) values (new.kodebrg,new.namabrg,new.kodegd,new.saldoawal*new.konv,new.saldoawal*new.konv);\n  else\n    Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)-old.saldoawal*old.konv where kodebrg=old.kodebrg and kodeGd= old.KodeGD;\n    Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)+new.saldoawal*new.konv where kodebrg=new.kodebrg and kodeGd= new.KodeGD;\n  END if;\n  END' 'CREATE DEFINER=`root`@`localhost` TRIGGER `SaldoAwalDelete` AFTER DELETE ON `tb_saldoawal` FOR EACH ROW BEGIN\ndeclare vtemp double;\n  select count(*) into vtemp from tm_stockbrg where kodebrg=old.kodebrg and kodeGd= old.KodeGD;\n  if vtemp > 0 then\n    Update tm_stockbrg set Stockakhir =  ifnull(stockakhir,0)-old.saldoawal*old.konv where kodebrg=old.kodebrg and kodeGd= old.KodeGD;\n  END if;\nEND'
sql_modes=524288 524288 524288
definers='root@localhost' 'root@localhost' 'root@localhost'
