清除 Oracle 会话状态
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12688317/
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
Clear Oracle session state
提问by oberstet
A database connection on Oracle can have session state that persists for the lifetime of the connection, i.e. in the form of package variables.
Oracle 上的数据库连接可以具有在连接的生命周期内持续存在的会话状态,即以包变量的形式。
Is there a way of flushing/clearing all that state between calls during a connection without killing the connection and reestablishing a new connection.
有没有办法在连接期间刷新/清除调用之间的所有状态而不终止连接并重新建立新连接。
I.e. consider a package variable first set in the package init, and later modified within some procedure in that package: how to "reset" the package so that multiple calls to the procedure from 1 connection always lead to a reinit of the package?
即考虑首先在包 init 中设置的包变量,然后在该包中的某个过程中进行修改:如何“重置”包,以便从 1 个连接多次调用该过程总是导致包的重新初始化?
In general: how to "reset" any session state between execution of statements from a client on that connection?
一般而言:如何在该连接上的客户端执行语句之间“重置”任何会话状态?
回答by René Nyffenegger
dbms_session.reset_package
is the closest I can think of. See this tahiti link.
dbms_session.reset_package
是我能想到的最接近的。请参阅此大溪地链接。
回答by Codo
Other than dbms_session.reset_package
(proposed in René Nyffenegger's answer), which resets all packages, you'll have to write your own package procedure to reset the state of a single package only. The procedure would just set all package variables to NULL (or whatever is appropriate).
除了dbms_session.reset_package
(在 René Nyffenegger 的回答中提出)重置所有包之外,您必须编写自己的包过程来仅重置单个包的状态。该过程只会将所有包变量设置为 NULL(或任何合适的值)。