oracle数据向历史表数据迁移————procedure

create or replace procedure remove_refund_his_pro is
begin
declare
cursor refund_query_cur is
select rowid from ucmp_realtime_refund_query t1
where t1.apply_tm<= TRUNC(ADD_MONTHS(SYSDATE, -3),'DD') AND ROWNUM <= '100000000';
TYPE rowid_table_type is table of rowid index by pls_integer;
v_rowid rowid_table_type;
begin
open refund_query_cur;
loop
fetch refund_query_cur bulk collect into v_rowid limit 100000;
exit when v_rowid.count=0;
forall i in v_rowid.first .. v_rowid.last
INSERT INTO HIS_REALTIME_REFUND_QUERY
(SELECT * FROM UCMP_REALTIME_REFUND_QUERY
WHERE rowid = v_rowid(i));
forall j in v_rowid.first .. v_rowid.last
DELETE FROM UCMP_REALTIME_REFUND_QUERY
WHERE rowid = v_rowid(j);
commit;
end loop;
close refund_query_cur;
end;
end remove_refund_his_pro;

posted @ 2016-05-18 17:10  别问1991  阅读(2726)  评论(3编辑  收藏  举报