Skip Headers

Oracle9i SQL Reference
Release 2 (9.2)

Part Number A96540-02
Go to Documentation Home
Go to Book List
Book List
Go to Table of Contents
Go to Index
Go to Master Index
Master Index
Go to Feedback page

Go to previous page Go to next page
View PDF



Use the ALTER FUNCTION statement to recompile an invalid standalone stored function. Explicit recompilation eliminates the need for implicit run-time recompilation and prevents associated run-time compilation errors and performance overhead.

The ALTER FUNCTION statement is similar to ALTER PROCEDURE. For information on how Oracle recompiles functions and procedures, see Oracle9i Database Concepts.


This statement does not change the declaration or definition of an existing function. To redeclare or redefine a function, use the CREATE FUNCTION statement with the OR REPLACE clause; see CREATE FUNCTION.


The function must be in your own schema or you must have ALTER ANY PROCEDURE system privilege.



Text description of statements_175.gif follows
Text description of alter_function



Specify the schema containing the function. If you omit schema, Oracle assumes the function is in your own schema.


Specify the name of the function to be recompiled.


Specify COMPILE to cause Oracle to recompile the function. The COMPILE keyword is required. If Oracle does not compile the function successfully, you can see the associated compiler error messages with the SQL*Plus command SHOW ERRORS.

During recompilation, Oracle drops all persistent compiler switch settings, retrieves them again from the session, and stores them at the end of compilation. To avoid this process, specify the REUSE SETTINGS clause.


Specify DEBUG to instruct the PL/SQL compiler to generate and store the code for use by the PL/SQL debugger.


Specify REUSE SETTINGS to prevent Oracle from dropping and reacquiring compiler switch settings. With this clause, Oracle preserves the existing settings and uses them for the recompilation.

If you specify both DEBUG and REUSE SETTINGS, Oracle sets the persistently stored value of the PLSQL_COMPILER_FLAGS parameter to INTERPRETED, DEBUG. No other compiler switch values are changed.

See Also:

PL/SQL User's Guide and Reference and Oracle9i Application Developer's Guide - Fundamentals for more information on the interaction of the PLSQL_COMPILER_FLAGS parameter with the COMPILE clause


Recompiling a Function: Example

To explicitly recompile the function get_bal owned by the sample user oe, issue the following statement:


If Oracle encounters no compilation errors while recompiling get_bal, get_bal becomes valid. Oracle can subsequently execute it without recompiling it at run time. If recompiling get_bal results in compilation errors, Oracle returns an error, and get_bal remains invalid.

Oracle also invalidates all objects that depend upon get_bal. If you subsequently reference one of these objects without explicitly recompiling it first, Oracle recompiles it implicitly at run time.