declare datDateFrom date := to_date('2010/08/01 00:00:00','yyyy/mm/dd hh24:mi:ss'); datDateTo date;begin while datDateFrom= datDateFrom and createdate < datDateTo; delete from dbproclog where createdate >= datDateFrom and createdate < datDateTo; commit; Insertlog(SYSDATE, 'dbproclog_delete', to_char(datDateFrom,'yyyy/mm/dd hh24:mi:ss') || ' to ' || to_char(datDateTo,'yyyy/mm/dd hh24:mi:ss') || ' deleted'); DBMS_LOCK.SLEEP(2); datDateFrom := datDateTo; end loop; execute immediate 'alter index DBPROCLOG_IDX2 rebuild ONLINE'; execute immediate 'alter index DBPROCLOG_IDX1 rebuild ONLINE';end;