create or replace procedure P_ANALYSE as
tname varchar2(100);
sql_sta varchar2(5000);
CURSOR cur is select * from CONFIGURE;
begin
open cur;
loop
fetch cur into tname;
exit when cur%notfound;
sql_sta :='exec dbms_stats.gather_table_stats(ownname => '||''''||'MARKET'||''''||',tabname => '||''''||tname||''''||',estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE,method_opt =>'||''''|| 'for all columns size auto'||''''||',degree => DBMS_STATS.AUTO_DEGREE,cascade=>TRUE,no_invalidate=>false)';
execute immediate sql_sta;
dbms_output.put_line(sql_sta);
end loop;
end P_ANALYSE;
其中sql_sta里面的是一条sqlplus命令,怎么使其执行
直接带入参数执行, 不用拼接成sql
exec dbms_stats.gather_table_stats(ownname => MARKET,tabname => tname,estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE,method_opt => 'for all columns size auto',degree => DBMS_STATS.AUTO_DEGREE,cascade=>TRUE,no_invalidate=>false)