You can use the ALTER FUNCTION statement to recompile an independent function.
Prerequisites
If the function is in the SYS schema, you must connect to the database with the SYSDBA role. Otherwise, the function must be located in your own schema, or you must have the ALTER ANY PROCEDURE system privilege.
Syntax
Syntax of ALTER FUNCTION:
ALTER FUNCTION [ schema. ] function_name
{ function_compile_clause } ;
Syntax of function_compile_clause:
COMPILE [ DEBUG ] [ compiler_parameters_clause ... ] [ REUSE SETTINGS ]
Semantics
| Syntax | Keyword or syntax node | Description |
|---|---|---|
| alter_function | schema | The name of the schema where the function is located. The default value is your schema. |
| alter_function | function_name | The name of the function to be recompiled. |
| function_compile_clause | - | Recompiles this function regardless of whether the function is valid. |
Examples
Explicitly recompile the get_salary_by_dept function of the SYS user.
ALTER FUNCTION sys.get_salary_by_dept COMPILE;
If the database does not encounter an error when it recompiles get_salary_by_dept, get_salary_by_dept becomes valid. The database can directly run this function later without recompiling it at run time.
If the database encounters an error when it recompiles the get_salary_by_dept function, it returns an error and invalidates get_salary_by_dept. The database also invalidates all objects that depend on get_salary_by_dept. If these objects are referenced later without being explicitly recompiled, the database will implicitly recompile the objects during running.