SQL 包的现有状态已被丢弃
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7920396/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Existing state of packages has been discarded
提问by Dan
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:
所以我一直在很好地运行 PLSQL 过程,并且编译没有错误。我对我的程序做了一个更改,它仍然可以正常编译,但是现在当我运行它时,我收到了这个错误:
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!
任何想法这可能是什么?我所做的更改是如此微不足道,以至于我怀疑它是否会导致此错误。预先感谢您的帮助!
回答by darreljnz
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.
为避免这种情况,请确保断开可能使用过该包的每个会话的连接,或者让该会话执行 DBMS_SESSION.RESET_PACKAGE 以重置包状态。
回答by Klas Lindb?ck
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.
此外,正如 darreljnz 所指出的,会话通常会保留对它们访问过的包状态的引用,从而导致ORA-04068: existing state of packages has been discarded
下次会话尝试引用包时。
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.
后一种行为是一个真正的麻烦,并且需要编写代码来重试操作或在安装新版本的包后关闭所有活动会话(有效地重新启动应用程序/服务)。底线:这使得安装修补程序变得更加困难。
回答by ThePallav_Abhi
Use pragma serially_reusable
in you Package and its Body.
使用pragma serially_reusable
在你包和它的身体。