Existing state of packages has been discarded

Use pragma serially_reusable in you Package and its Body.


When a session makes use of a package that session retains some state of the package. If that package is recompiled the next time the same session references the package you'll get that error.

To avoid this make sure you disconnect each session that may have used the package or have the session do a DBMS_SESSION.RESET_PACKAGE to reset the package state.


If you recompile a package specification all dependant objects are invalidated. A dependant object is any view, package specification, package body, function or procedure that references any of the declarations in the recompiled package specification.

Also, as pointed out by darreljnz, sessions usually retain references to the state of packages they have accessed, causing an ORA-04068: existing state of packages has been discarded the next time the session tries to reference the package.

This latter behaviour is a real nuisence and makes it necessary to either write code to retry operations or to close all active sessions after installing a new version of a package (effectively restarting the application/service). Bottom line: It makes it harder to install hotfixes.