根据ID初始化数据

Posted by Vincent on February 2, 2009

根据序列ID初始化数据,可以很好的完成并行和增量。 但如果中断需要重新跑那些中断了的进程。
速度一般,没有extend来的快。 适合需要增量来做的情况
[cc lang="sql"]
create or replace procedure SP_FB_INT_COL
(id_start number,id_end number) is
/*
create by 玄风
date: 2009-2-1
初始表两个新增字段
parenttradeid 主订单号
validfeedback 是否存在内容
*/

i number;
j number;
n number;
loop_time number;

begin
--确定循环次数
loop_time := (id_end - id_start) / 10000 + 1;
i := id_start; --初始ID

for loop_c in 1 .. loop_time loop
--确定该次循环的最大ID
if j + 10000 <= id_end then
j := j + 10000;
else
j := id_end;
end if;

for c in (select rowid rid
from auc_feed
where id >= i
and id < j) loop

update auc_feed au
set au.parenttradeid = au.trade_id,
au.validfeedback = decode(au.feedback,
null,
0,
'默认好评!',
0,
1)
where au.rowid = c.rid;

n := n + 1;
if mod(n, 100) = 0 then
commit;
end if;

end loop;
commit;
--确定下次循环的最小ID
i := j;
end loop;

end SP_FB_INT_COL;
/
[/cc]


This work is licensed under a CC A-S 4.0 International License.