update TousseItem set materialAmount=(select sum(mi.count) from TousseDefinition td inner join MaterialInstance mi on mi.tousse_id = td.id where tousseitem.toussedefinitionid=td.id);
update RecyclingItem set materialAmount=(select sum(mi.count) from TousseDefinition td inner join MaterialInstance mi on mi.tousse_id = td.id where recyclingitem.toussedefinitionid=td.id);
update ClassifiedItem set materialAmount=(select sum(mi.count) from TousseDefinition td inner join MaterialInstance mi on mi.tousse_id = td.id where classifieditem.toussedefinition_id=td.id);
update PackingRecord set materialAmount=(select sum(mi.count) from TousseDefinition td inner join MaterialInstance mi on mi.tousse_id = td.id where PackingRecord.tousseDefinitionId=td.id);
update TousseInstance set materialAmount=(select sum(mi.count) from TousseDefinition td inner join MaterialInstance mi on mi.tousse_id = td.id where TousseInstance.toussedefinition_id=td.id);
update InvoiceItem set materialAmount=(select sum(mi.count) from TousseDefinition td inner join MaterialInstance mi on mi.tousse_id = td.id where InvoiceItem.tousseDefinitionId=td.id);
update ReturnGoodsItem set materialAmountAtThatTime=(select sum(mi.count) from TousseDefinition td inner join MaterialInstance mi on mi.tousse_id = td.id where ReturnGoodsItem.toussedefinition_id=td.id);
update TousseDefinition set materialAmount=(select sum(mi.count) from MaterialInstance mi where mi.tousse_id = TousseDefinition.id); 