1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
| CREATE OR REPLACE PROCEDURE "prc_AnalyseTablePartition" (pi_table_owner varchar2,
pi_cnom_table varchar2 , pi_cyear varchar2) is
CURSOR C_PARAM (p_table_owner varchar2,p_cnom_table varchar2 , p_cyear varchar2) is
select distinct('dbms_stats.GATHER_TABLE_STATS(OWNNAME => ''' || p_table_owner || ''',TABNAME => ''' || ai.table_name ||''',PARTNAME => ''' || partition_name || ''' , CASCADE => FALSE, METHOD_OPT => ''FOR ALL INDEXED COLUMNS'', GRANULARITY => ''PARTITION'');') cleTexte
from all_indexes ai,all_tab_partitions atp
where atp.table_name = p_cnom_table
and atp.table_owner = p_table_owner
and substr(partition_name,5,4) >= p_cyear
and atp.table_name = ai.table_name
and atp.table_owner = ai.table_owner
;
L_PARAM C_PARAM%ROWTYPE;
v_select varchar2(3000);
cursor1 integer;
v_text varchar2(300);
begin
Open C_PARAM(pi_table_owner,pi_cnom_table, pi_cyear);
While (1=1)
Loop
Fetch C_PARAM into L_PARAM;
If (C_PARAM%FOUND)
Then
begin
cursor1 := dbms_sql.open_cursor;
dbms_sql.parse(cursor1, l_param.cleTexte, dbms_sql.native);
dbms_sql.close_cursor(cursor1);
End;
else
exit;
end if;
End Loop;
close C_PARAM;
end; |