我们可以通过这种方式在动态光标中使用批量删除吗?



我们可以使用立即执行进行批量删除,例如(对于游标)

forall i in rowid.FIRST .. rowid.LAST
Execute Immediate 'DELETE table_name '||PARTIION_NAME||'where rowid =rowid(m)';

有没有其他方法来完成这项工作...?感谢iN前进

我真的不明白你想用||PARTIION_NAME||做什么,但你可以做这样的事情:

DECLARE
  type rowid_tab is table of rowid;
  rowids rowid_tab;
  cursor c is select rowid from table_name where <some condition>;
BEGIN
  open c;
  fetch c bulk collect into rowids;
  close c;
  -- here is where the "real thing" starts
  forall i in rowids.first .. rowids.last 
    execute immediate 'delete table_name where rowid = :1' using rowids(i);
  commit;  
END;

但我必须问 - 为什么?

最新更新