update T_PUR_SALOUTSTOCKENTRY s set FEntryStatus  ='B' where fentryid in ( select s.fentryid FROM T_PUR_SALOUTSTOCKENTRY_A a where  s.fentryid = a.fentryid and( ( a.FSumReceiptQty + s.frejectqty >= s.FQty ) or  (a.fsuminstockqty + s.frejectqty >= s.FQty )));