declare
cursor product_id_list is
select product_id from online_product where status = 'ON';
commit_count number := 0;
total_count number := 0;
begin
for pid in product_id_list loop
total_count := total_count + 1;
commit_count := commit_count + 1;
update online_product setonline_flag = '0'
where status = 'ON'
and product_id = pid.product_id;
if commit_count > 1000 then
commit;
commit_count := 0;
end if;
end loop;
commit;
dbms_output.put_line('Total Count:' || total_count);
end;
下面这个和我的很相似,不用自己写了,就用他的吧!最近做了一个需求,需要批量更新数据库表,但是因为涉及到的数据较多(千万条),如果直接用sql更新,估计会把pl/sql弄垮sql如下:update online_product set online_flag = '0' where status = 'ON'所以,写了一个存储过程,以备忘:1234567891011121314151617181...