The AskTOM team is taking a break over the holiday season, so we're not taking questions or responding to comments. Please have a happy and safe festive season and as always, thanks for being a member of the AskTOM community.
Thanks for the question.
Asked: September 15, 2016 - 4:28 am UTC
Last updated: September 17, 2016 - 3:49 am UTC
Version: oracle
Viewed 1000+ times
SQL> create table t ( tname varchar2(30) ); Table created. SQL> SQL> insert into t values ('TAB1'); 1 row created. SQL> insert into t values ('TAB2'); 1 row created. SQL> SQL> set serverout on SQL> declare 2 del_stmt varchar2(1000); 3 begin 4 for i in ( select tname from t ) loop 5 del_stmt := 'delete from '||i.tname; 6 dbms_output.put_line(del_stmt); 7 execute immediate del_stmt; 8 end loop; 9 end; 10 / delete from TAB1 delete from TAB2 PL/SQL procedure successfully completed. SQL> SQL>
Check out more PL/SQL tutorials on our LiveSQL tool.
PL/SQL reference manual from the Oracle documentation library