oracle 批量修改数据
T_SQL批量更新语句
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
--更新tab1 col1和更新时间,共?条 set serveroutput on; declare execCnt NUMBER := 0; cursor cur_cdr is select id from tab1 where PLATFORM = 'Amazon' AND col1 IS NULL; type type_tab1_id is table of tab1.id%type; table_tab1_id type_tab1_id; ln_cnt number := 0; begin open cur_cdr; loop fetch cur_cdr bulk collect into table_tab1_id limit 1000; ln_cnt := ln_cnt + table_tab1_id.count; execCnt:= execCnt+ ln_cnt; dbms_output.put_line('执行结果: number:' || execCnt); -- forall i in 1 .. table_rowid.count For i In 1 .. table_tab1_id.Count loop update tab1 set col1 = 0,UPDATE_DATETIME=sysdate where id=table_tab1_id(i); ln_cnt := ln_cnt - 1; end loop; commit; exit when cur_cdr%notfound or cur_cdr%notfound is null; end loop; close cur_cdr; commit; end;