create or replace procedure p_insert_ofsa(v_banks_no in number,v_date_no in char,v_loop in number) is
------------脚本p_insert_ofsa说明-----------------------------------
--目的: 创建OFSA表的所有存量数据
--算法: 创建临时表tmp,从tmp中依次创建T1结果表
--说明: v_banks_no表示分行起始编号(11-37),v_date表示月末日期,v_loop表示分行总数
--使用方法:p_insert_ofsa(22,'2009-01-31',8)
--执行六次,每次更改时间参数,则生成六个月的数据
v_counter number(2) := 1;
v_bank_no_num number(2) := v_banks_no;
v_date date := to_date(v_date_no,'yyyy-mm-dd');
begin
insert into FEM_COMMERCIAL_LOANS_tmp select * from FEM_COMMERCIAL_LOANS;
commit;
/*生成X家行一个月的数据*/
for v_counter in 1 .. v_loop loop
--贷款表
insert /*+ append nologging parallel(FEM_COMMERCIAL_LOANS 8) */
into FEM_COMMERCIAL_LOANS
(IDENTITY_CODE,
ID_NUMBER,
XX_ID_NUMBER,
……)
select /*+ parallel(FEM_COMMERCIAL_LOANS_tmp 8) */
IDENTITY_CODE,
substr(ID_NUMBER,1,3)||test_myseq.nextval,
v_bank_no_num || XX_ID_NUMBER,
……
from FEM_COMMERCIAL_LOANS_tmp;
commit;
v_bank_no_num := v_bank_no_num + 1;
end loop;
end p_insert_ofsa;