Oracle 更新一百万条数据

DECLARE
  INDE NUMBER := 0;
BEGIN
  FOR R IN (SELECT /*+ INDEX(T IDX_INV_03)*/
             T.ROWID ROID
              FROM TT_INV_DATE T, TT_INT_CONFIG T1
             WHERE T.PT_CODE = T1.INV_PT_CODE
               AND T1.CON_CODE = '1122'
               AND T.INV_TM > DATE '2014-06-01'
               AND T.INV_TM < DATE '2014-07-31'
               AND T.REA_CODE = '124'
               AND T.IS_UPLOADED = 1) LOOP
    INDE := INDE + 1;
    UPDATE TT_INV_DATE T SET T.IS_UPLOADED = 0 WHERE T.ROWID = R.ROID;
  
    IF INDE / 50000 = 1 THEN
      INDE := 0;
      COMMIT;
    END IF;
  END LOOP;
  COMMIT;
EXCEPTION
  WHEN OTHERS THEN
    ROLLBACK;
    DBMS_OUTPUT.put_line('update error');
END;

 

你可能感兴趣的:(oracle)