I am trying to write a small script to use in SQL*Plus to compile invalid objects. My schema has invalid objects, however when I run this code, I get the following error: ORA-00900: invalid SQL statement. If I run the SQL statement produced by the "select", it runs fine. What am I overlooking?
DECLARE
cmd VARCHAR2(256);
BEGIN
FOR rec in (select chr(39)||'Alter '||object_type||' '||object_name||' compile'||chr(39) cmd from user_objects where status = 'INVALID')
LOOP
dbms_output.put_line(rec.cmd);
execute immediate rec.cmd;
end loop;
END;
/
DECLARE
cmd VARCHAR2(256);
BEGIN
FOR rec in (select chr(39)||'Alter '||object_type||' '||object_name||' compile'||chr(39) cmd from user_objects where status = 'INVALID')
LOOP
dbms_output.put_line(rec.cmd);
execute immediate rec.cmd;
end loop;
END;
/