码迷,mamicode.com
首页 > 数据库 > 详细

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

时间:2016-05-18 17:46:56      阅读:837      评论:0      收藏:0      [点我收藏+]

标签:

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;

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

标签:

原文地址:http://www.cnblogs.com/lianshan/p/5505881.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!