程序包的现有状态已废弃-Oracle [英] Existing state of package discarded - Oracle

查看:79
本文介绍了程序包的现有状态已废弃-Oracle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Oracle,并且在某些触发器和程序包上修改了代码. 当我运行用于修改代码的脚本文件并尝试在表上进行更新(这会触发触发器)时,我将废弃软件包的现有状态

I am using Oracle and I have modified code on some triggers and a package. When I run the script file which modifies the code and try to do an update on a table (which fires the trigger) I am getting Existing State of Package discarded

我遇到了很多错误

ORA-04068:
ORA-04061:
ORA-04065:
ORA-06512:--Trigger error -- line 50
ORA-04088:

此错误仅在第一次发生.避免这种情况的任何投入将不胜感激.谢谢!

This error is happening only the first time. Any inputs to avoid this would be greatly appreciated. Thank you!

推荐答案

serially_reusable仅对常量包变量有意义.

serially_reusable only makes sense for constant package variables.

只有一种方法可以避免此错误并保持性能(reset_package实际上不是一个好选择).避免在PL/SQL软件包中使用任何软件包级别的变量. Oracle的服务器内存不是存储状态的正确位置.

There is only one way to avoid this error and maintain performance (reset_package is really not a good option). Avoid any package level variables in your PL/SQL packages. Your Oracle's server memory is not the right place to store state.

如果某些事情确实没有改变,计算起来很昂贵,并且函数的返回值可以一遍又一遍地重用而无需重新计算,那么DETERMINISTIC可以在这方面提供帮助

If something really does not change, is expensive to compute and a return value from a function can be reused over and over without recomputation, then DETERMINISTIC helps in that regard

示例:请勿执行以下操作: varchar2(100)cached_result;

example: DON'T DO THIS: varchar2(100) cached_result;

function foo return varchar2 is
begin
  if cached_result is null then
     cached_result:= ... --expensive calc here
  end if; 
 return cached_result;
end foo;

不要这样做

function foo return varchar2 DETERMINISTIC is
begin
  result:=... --expensive calc here
  return result;
end foo;

确定性告诉Oracle,对于给定的输入,结果不会更改,因此可以缓存结果并避免调用函数.

Deterministic tells Oracle that for a given input, the result does not change, so it can cache the result and avoid calling the function.

如果这不是您的用例,则需要在各个会话之间共享变量,请使用表并对其进行查询.如果以任何频率使用表,该表将最终位于缓冲区高速缓存中,因此您可以获得所需的内存存储,而不会出现会话变量的问题

If this is not your use case and you need to share a variable across sessions, use a table, and query it. Your table will end up in the buffer cache memory if it is used with any frequency, so you get the in memory storage you desire without the problems of session variables

这篇关于程序包的现有状态已废弃-Oracle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆