The code below works perfectly well
- Code: Select all
begin
for cur_str IN (select 'alter table '||table_owner||'.'||table_name||' move partition '||partition_name||
' $3 tablespace PART_DATA_' || PARTITION_YR || ' parallel $2' ddl_stmt
from dba_tab_partitions
where partition_name=part_rec.part_name
and table_owner = '$SCH'
and table_name=part_rec.tab_name)
loop
DBMS_OUTPUT.put_line (cur_str.ddl_stmt);
execute immediate (cur_str.ddl_stmt)
end loop;
exception
when no_data_found then
NULL;
when others then
dbms_output.put_line('ERROR: failed due to '||sqlerrm) ;
end;
but the problem is while its executing we never are aware of the progress. Hence we are trying to get the results of each statement executed by "EXECUTE IMMEDIATE". so meaning while code proceeds to second SQL we should somehow be able to know the what were the results of the first statement execution. DBMS_OUTPUT.put_line (cur_str.ddl_stmt) gives us the statement thats being executed but we never know what were the results even if we are spooling in the beginning of the code.
Pls assist.
I tried something like
- Code: Select all
begin
for cur_str IN (select 'alter table '||table_owner||'.'||table_name||' move partition '||partition_name||
' $3 tablespace PART_DATA_' || PARTITION_YR || ' parallel $2' ddl_stmt
from dba_tab_partitions
where partition_name=part_rec.part_name
and table_owner = '$SCH'
and table_name=part_rec.tab_name)
loop
DBMS_OUTPUT.put_line (cur_str.ddl_stmt);
execute immediate 'cur_str.ddl_stmt' into abc;
dbms_output.put_line(abc);
end loop;
exception
when no_data_found then
NULL;
when others then
dbms_output.put_line('ERROR: failed due to '||sqlerrm) ;
end;
It failed.
Pls assist.