可是如下过程创建没问题,调用时报错,请予以指教不胜感激: --目的:重编译所有对象 create or replace procedure p_compile is v_str varchar2(200):='ALTER '||'''object_type'''||' '||'''object_name'''||' recompile;'; v_success varchar2(60):='compiled no successful!'; cursor mycursor is select v_str from user_objects where object_type in ('VIEW','TRIGGER','PROCEDURE','FUNCTION','PACKAGE','PACKAGE BODY'); --v_lstr varchar2; --type tarr is varray(100) of number; --tarry tarr :=tarr(); begin for c_re in mycursor loop execute immediate ltrim(rtrim(replace(c_re.v_str,''''))); commit; end loop; v_success :='compiled successfully!'; dbms_output.put_line(v_success); end p_compile; SQL> conn zzy/030136@oemrep 已连接。 SQL> execute p_compile BEGIN p_compile; END;* ERROR 位于第 1 行: ORA-00940: 无效的 ALTER 命令 ORA-06512: 在"ZZY.P_COMPILE", line 13 ORA-06512: 在line 1 SQL>
--目的:重编译所有对象
create or replace procedure p_compile
is
v_str varchar2(200):='ALTER '||'''object_type'''||' '||'''object_name'''||' recompile;';
v_success varchar2(60):='compiled no successful!';
cursor mycursor is
select v_str from user_objects where object_type
in ('VIEW','TRIGGER','PROCEDURE','FUNCTION','PACKAGE','PACKAGE BODY');
--v_lstr varchar2;
--type tarr is varray(100) of number;
--tarry tarr :=tarr();
begin
for c_re in mycursor loop
execute immediate ltrim(rtrim(replace(c_re.v_str,'''')));
commit;
end loop;
v_success :='compiled successfully!';
dbms_output.put_line(v_success);
end p_compile;
SQL> conn zzy/030136@oemrep
已连接。
SQL> execute p_compile
BEGIN p_compile; END;*
ERROR 位于第 1 行:
ORA-00940: 无效的 ALTER 命令
ORA-06512: 在"ZZY.P_COMPILE", line 13
ORA-06512: 在line 1
SQL>