update ReturnMaterialRecord set settleAccountsDepartCoding = (select orgUnitCoding from SupplyRoomConfig where supplyRoomType = 4 and orgUnitCoding = (select settleAccountsDepartCoding from SupplyRoomConfig where supplyRoomType = 3 and orgUnitCoding = ReturnMaterialRecord.departCoding and settleAccountsDepartCoding is not null and settleAccountsDepartCoding <> '')) where settleAccountsDepartCoding is null; update ReturnMaterialRecord set settleAccountsDepart = (select orgUnitName from SupplyRoomConfig where supplyRoomType = 4 and orgUnitCoding = (select settleAccountsDepartCoding from SupplyRoomConfig where supplyRoomType = 3 and orgUnitCoding = ReturnMaterialRecord.departCoding and settleAccountsDepartCoding is not null and settleAccountsDepartCoding <> '')) where settleAccountsDepart is null; update ReturnMaterialRecord set settleAccountsDepartCoding = departCoding, settleAccountsDepart = depart where settleAccountsDepartCoding is null and settleAccountsDepart is null; update MaterialInvoice set settleAccountsDepartCoding = (select orgUnitCoding from SupplyRoomConfig where supplyRoomType = 4 and orgUnitCoding = (select settleAccountsDepartCoding from SupplyRoomConfig where supplyRoomType = 3 and orgUnitCoding = MaterialInvoice.departCoding and settleAccountsDepartCoding is not null and settleAccountsDepartCoding <> '')) where settleAccountsDepartCoding is null; update MaterialInvoice set settleAccountsDepart = (select orgUnitName from SupplyRoomConfig where supplyRoomType = 4 and orgUnitCoding = (select settleAccountsDepartCoding from SupplyRoomConfig where supplyRoomType = 3 and orgUnitCoding = MaterialInvoice.departCoding and settleAccountsDepartCoding is not null and settleAccountsDepartCoding <> '')) where settleAccountsDepart is null; update MaterialInvoice set settleAccountsDepartCoding = departCoding, settleAccountsDepart = depart where settleAccountsDepartCoding is null and settleAccountsDepart is null; update MaterialErrorDamageDetail set settleAccountsDepartCoding = (select orgUnitCoding from SupplyRoomConfig where supplyRoomType = 4 and orgUnitCoding = (select settleAccountsDepartCoding from SupplyRoomConfig where supplyRoomType = 3 and orgUnitCoding = MaterialErrorDamageDetail.departCode and settleAccountsDepartCoding is not null and settleAccountsDepartCoding <> '')) where settleAccountsDepartCoding is null; update MaterialErrorDamageDetail set settleAccountsDepart = (select orgUnitName from SupplyRoomConfig where supplyRoomType = 4 and orgUnitCoding = (select settleAccountsDepartCoding from SupplyRoomConfig where supplyRoomType = 3 and orgUnitCoding = MaterialErrorDamageDetail.departCode and settleAccountsDepartCoding is not null and settleAccountsDepartCoding <> '')) where settleAccountsDepart is null; update MaterialErrorDamageDetail set settleAccountsDepartCoding = departCode,settleAccountsDepart=depart where settleAccountsDepartCoding is null;