--初始化出库单汇总,去除出库任务单,清空波次号
update out_sale_billing_m set sf_ycw_sl='否' where DJBH ='XHBB00000414140';
BEGIN
FOR C IN (SELECT * FROM OUT_SALE_BILLING_M WHERE DJBH ='XHBB00000414140') LOOP
UPDATE out_sale_billing_m T
SET zyzt ='0',T.SF_YCW_SL ='否',t.sf_gq='否'--,SF_YBDD='否'
WHERE djbh = c.djbh
AND yzid = c.yzid;

UPDATE out_sale_billing_D T
   SET zyzt ='0',T.SL_LHWCL =T.SL,T.SL_ZJWCL =0, T.SL_KCBZ = 0,t.sf_gq='否',T.SF_YCW_SL ='否'
 WHERE djbh = c.djbh
   AND yzid = c.yzid;    

DELETE FROM OUT_SALE_TASK_D WHERE DJBH= C.DJBH AND YZID = C.YZID;
DELETE FROM OUT_SALE_TASK_M WHERE DJBH= C.DJBH AND YZID = C.YZID;

END LOOP;
END;

UPDATE out_sale_billing_m set BCH='' WHERE DJBH ='XHBB00000414140';