|
|||||||||||||
|
|
Here, if you recompile a program, Oracle will first recompile any objects upon which that program depends and which are marked INVALID. Example I: Compile Procedure ACCESS_RIGHTS located in MYUSER schema.
DBMS_DDL.ALTER_COMPILE('PROCEDURE','MYUSER','ACCESS_RIGHTS');
Example II: In almost every instance, the names of the PL/SQL objects are stored in uppercase. If you specify an object name in double quotes while creating it, then the same case has to be specified while compiling. If you specify an incorrect case, the following error is displayed.
SQL> dbms_ddl.alter_compile('PROCEDURE','MYUSER','access_rights');
BEGIN dbms_ddl.alter_compile('PROCEDURE','MYUSER','access_rights'); END;
*
ERROR at line 1:
ORA-20000: Unable to compile PROCEDURE "MYUSER"."access_rights",
So if you create an object as below: CREATE or REPLACE PROCEDURE "My_Object" IS BEGIN ... then use:
DBMS_DDL.ALTER_COMPILE('PROCEDURE','MYUSER','My_Object');
You can choose to use ALTER PROCEDURE <procedure name> COMPILE command to compile objects. One big advantage of using the DBMS_DDL package is that you can use the latter within PL/SQL block or program. This gives you full flexibility to put it to a powerful use (please refer to the example below). Example III: In this example we will get all the INVALID objects and re-compiles them. set termout on set serverout on DECLARE cursor cur_invalid_objects is select object_name, object_type from user_objects where status='INVALID'; rec_columns cur_invalid_objects%ROWTYPE; err_status NUMERIC; BEGIN dbms_output.enable(10000); open cur_invalid_objects; loop fetch cur_invalid_objects into rec_columns; EXIT WHEN cur_invalid_objects%NOTFOUND; dbms_output.put_line SummaryThe ALTER_COMPILE thus allows compiling of the objects automatically instead of manually, finding all the objects, which are INVALID, and then compiling them one by one.
|
||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]()