Reputation: 1588
So I have been running a PLSQL procedure just fine, and compiling with no errors. I made one change to my procedure, and it still compiles fine, but now when I run it, I get this error:
ERROR at line 1:
ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package body "SCHEMA.XP_COVER_PAGEP" has been invalidated
ORA-04065: not executed, altered or dropped package body "SCHEMA.XP_COVER_PAGEP"
ORA-06508: PL/SQL: could not find program unit being called: "SCHEMA.XP_COVER_PAGEP"
ORA-06512: at "SCHEMA.XP_ST_002180", line 141
ORA-06512: at line 1
Any ideas what this could be? The change I made was so insignificant that I doubt it could have caused this error. Thank you in advance for your help!
Upvotes: 25
Views: 47810
Reputation: 33273
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.
Upvotes: 6
Reputation: 2380
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.
Upvotes: 36