update Invoice set departCoding=(select departCoding from invoicePlan where id=Invoice.invoicePlan_ID) where invoicePlan_ID is not null; update Invoice set settleAccountsDepartCoding=(select settleAccountsDepartCoding from invoicePlan where id=Invoice.invoicePlan_ID) where invoicePlan_ID is not null; update Invoice set invoicePlanType=(select type from invoicePlan where id=Invoice.invoicePlan_ID) where invoicePlan_ID is not null; update Invoice set departCoding=(select orgunitcoding from orgunit where name=invoice.depart),settleaccountsdepartcoding=(select orgunitcoding from orgunit where name=invoice.depart) where invoiceplan_id is null and departcoding is null;