It will just be case of building the appropriate anonymous block dynamically.
For example, I can extend mine to loops, eg
SQL> select
2 'begin '||chr(10)||
3 'loop '||chr(10)||
4 'delete from '||tab_name||' where '||pk_column||chr(10)||
5 ' in ( select id from myids) and rownum <= 100000;'||chr(10)||
6 'exit when sql%rowcount < 100000; '||chr(10)||
7 'commit;'||chr(10)||
8 'end loop;'||chr(10)||
9 'commit;'||chr(10)||
10 'end;' anon_blk
11 from meta;
ANON_BLK
------------------------------------------------------------------------------
begin
loop
delete from t1 where id
in ( select id from myids) and rownum <= 100000;
exit when sql%rowcount < 100000;
commit;
end loop;
commit;
end;
begin
loop
delete from t2 where id2
in ( select id from myids) and rownum <= 100000;
exit when sql%rowcount < 100000;
commit;
end loop;
commit;
end;
A quick "hack" to constructing these things is to write a *static* version of what you want and then just substitute in variables. For example, rather than "build" the string like I did above, I could do this:
SQL> variable the_block varchar2(1000);
SQL> begin
2 :the_block :=
3 'begin
4 loop
5 delete from @@TAB@@
6 where @@COL@@ in
7 ( select id
8 from myids)
9 and rownum <= 100000;
10 exit when sql%rowcount < 100000;
11 commit;
12 end loop;
13 commit;
14 end;';
15 end;
16 /
PL/SQL procedure successfully completed.
SQL>
SQL> select
2 replace(replace(:the_block,'@@TAB@@',tab_name),'@@COL@@',pk_column) x
3 from meta;
X
----------------------------------------------------------------------------------------
begin
loop
delete from t1
where id in
( select id
from myids)
and rownum <= 100000;
exit when sql%rowcount < 100000;
commit;
end loop;
commit;
end;
begin
loop
delete from t2
where id2 in
( select id
from myids)
and rownum <= 100000;
exit when sql%rowcount < 100000;
commit;
end loop;
commit;
end;
Much easier than concatenating strings etc