UPDATE T_CAS_RECEIVINGBILLENTRY SET FUNSETTLEDAMOUNT = FRECEIVABLEAMOUNT,FUNLOCKAMOUNT = FRECEIVABLEAMOUNT WHERE FSETTLEORGID = 0;

UPDATE T_CAS_RECEIVINGBILLENTRY t
   SET FSETTLEORGID =
       (SELECT FOPENORGID FROM T_CAS_RECEIVINGBILL g WHERE g.FID = t.FID)
 WHERE FSETTLEORGID = 0
   AND exists (SELECT 1 FROM T_CAS_RECEIVINGBILL g WHERE g.FID = t.FID);

UPDATE T_CAS_PAYMENTBILLENTRY SET FUNSETTLEDAMOUNT = FPAYABLEAMOUNT,FUNLOCKAMOUNT = FPAYABLEAMOUNT WHERE FSETTLEORGID = 0;
   
UPDATE T_CAS_PAYMENTBILLENTRY t
   SET FSETTLEORGID =
       (SELECT FOPENORGID FROM T_CAS_PAYMENTBILL g WHERE g.FID = t.FID)
 WHERE FSETTLEORGID = 0
   AND exists (SELECT 1 FROM T_CAS_PAYMENTBILL g WHERE g.FID = t.FID);
