Skip Headers

Oracle® Database SQL Reference
10g Release 1 (10.1)

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

Go to previous page
Previous
Go to next page
Next
View PDF

ALTER PACKAGE

Purpose

Use the ALTER PACKAGE statement to explicitly recompile a package specification, body, or both. Explicit recompilation eliminates the need for implicit run-time recompilation and prevents associated run-time compilation errors and performance overhead.

Because all objects in a package are stored as a unit, the ALTER PACKAGE statement recompiles all package objects together. You cannot use the ALTER PROCEDURE statement or ALTER FUNCTION statement to recompile individually a procedure or function that is part of a package.


Note:

This statement does not change the declaration or definition of an existing package. To redeclare or redefine a package, use the CREATE PACKAGE or the CREATE PACKAGE BODY statement with the OR REPLACE clause.

Prerequisites

For you to modify a package, the package must be in your own schema or you must have ALTER ANY PROCEDURE system privilege.

Syntax


alter_package::=
Description of alter_package.gif follows
Description of the illustration alter_package.gif


compiler_parameters_clause::=
Description of compiler_parameters_clause.gif follows
Description of the illustration compiler_parameters_clause.gif

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 of any parameters for which values are not specified elsewhere in this statement.

For backward compatibility, Oracle Database sets the persistently stored value of the PLSQL_COMPILER_FLAGS initialization parameter to reflect the values of the PLSQL_CODE_TYPE and PLSQL_DEBUG parameters that result from this statement.

Examples


Recompiling a Package: Examples

This statement explicitly recompiles the specification and body of the hr.emp_mgmt package, which was created in "Creating a Package: Example":

ALTER PACKAGE emp_mgmt
   COMPILE PACKAGE; 

If Oracle Database encounters no compilation errors while recompiling the emp_mgmt specification and body, then emp_mgmt becomes valid. The user hr can subsequently call or reference all package objects declared in the specification of emp_mgmt without run-time recompilation. If recompiling emp_mgmt results in compilation errors, then Oracle Database returns an error and emp_mgmt remains invalid.

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

To recompile the body of the emp_mgmt package in the schema hr, issue the following statement:

ALTER PACKAGE hr.emp_mgmt 
   COMPILE BODY; 

If Oracle Database encounters no compilation errors while recompiling the package body, then the body becomes valid. The user hr can subsequently call or reference all package objects declared in the specification of emp_mgmt without run-time recompilation. If recompiling the body results in compilation errors, then Oracle Database returns an error message and the body remains invalid.

Because this statement recompiles the body and not the specification of emp_mgmt, Oracle Database does not invalidate dependent objects.