存储过程动态执行SQL
CREATE OR REPLACE PROCEDURE "KM"."UPDATE_INST_META_PRO"
??? is
???? cursor cur is select * from recovery_inst_currmeta where flag = 0 and rownum < 1000;
???? str varchar2(1024);
begin
??????? dbms_output.put_line('Begin...');
??????? for item in cur loop
????????? begin
???????????? str:='' || item.update_sql || '';
???????????? dbms_output.put_line('finished: ' || str);
???????????? EXECUTE IMMEDIATE str;
???????????? update recovery_inst_currmeta set flag = 1 where update_sql = item.update_sql;
???????????? commit;
????????? end;
??????? end loop;
??????? dbms_output.put_line('End!');
? end;
/