ORA-06508:PL/SQL:找不到正在被调用的程序单元 [英] ORA-06508: PL/SQL: could not find program unit being called

查看:2948
本文介绍了ORA-06508:PL/SQL:找不到正在被调用的程序单元的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Oracle 10g和Toad 11.5.我正在尝试从匿名块中调用api.

I am using oracle 10g and toad 11.5. I am trying to call an api from an anonymous block.

如果我在添加dbms_output.put_line之后重新编译api,然后尝试执行匿名块,它将显示错误为

If i recompile the api after adding dbms_output.put_line and then try to execute the anonymous block ,it shows error as

"ORA-06508: PL/SQL: could not find program unit being called".

但是,如果我结束当前会话并打开一个新会话,则匿名块将执行而不会出现错误.

However if i end current session and open a new session , then the anonymous block will execute with out the error.

由于这个问题,我每次更改API时都要重新连接会话. 如果可以通过在Toad或数据库级别进行任何配置来解决此问题,那么任何人都可以提供帮助.

Due to this issue, i am made to reconnect the session everytime i make a change to API. Can anyone help if this issue can be resolved by making any configurations in toad or database level.

推荐答案

我怀疑您只是在报告堆栈中的最后一个错误,如下所示:

I suspect you're only reporting the last error in a stack like this:

ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package body "schema.package" has been invalidated
ORA-04065: not executed, altered or dropped package body "schema.package"
ORA-06508: PL/SQL: could not find program unit being called: "schema.package"

如果是这样,那是因为您的程序包是有状态的:

If so, that's because your package is stateful:

包中的变量,常量和游标的值 声明(在其规范或正文中)组成其程序包 状态.如果PL/SQL包声明了至少一个变量,常量, 或游标,则说明该软件包为有状态;否则,它是无状态.

The values of the variables, constants, and cursors that a package declares (in either its specification or body) comprise its package state. If a PL/SQL package declares at least one variable, constant, or cursor, then the package is stateful; otherwise, it is stateless.

重新编译时状态会丢失:

When you recompile the state is lost:

如果实例化的有状态程序包的主体被重新编译(或者 使用"ALTER PACKAGE语句"显式地或隐式地), 软件包中子程序的下一次调用会导致Oracle数据库 放弃现有的包状态并引发异常 ORA-04068.

If the body of an instantiated, stateful package is recompiled (either explicitly, with the "ALTER PACKAGE Statement", or implicitly), the next invocation of a subprogram in the package causes Oracle Database to discard the existing package state and raise the exception ORA-04068.

在PL/SQL引发异常之后,对该包的引用导致 Oracle数据库重新实例化该软件包,该软件包重新初始化 它...

After PL/SQL raises the exception, a reference to the package causes Oracle Database to re-instantiate the package, which re-initializes it...

如果您的包裹有状态,您将无法避免.我认为真正需要一个程序包是有状态的是很少见的,因此您应该重新访问在程序包中声明的所有内容,但要在函数或过程之外,以查看在该级别上是否确实需要它.由于您使用的是10g,因此其中包含常量,而不仅仅是变量和游标.

You can't avoid this if your package has state. I think it's fairly rare to really need a package to be stateful though, so you should revisit anything you have declared in the package, but outside a function or procedure, to see if it's really needed at that level. Since you're on 10g though, that includes constants, not just variables and cursors.

但是引用的文档中的最后一段意味着下次在同一会话中引用该软件包时,您将不会收到错误,并且它将正常运行(直到再次重新编译).

But the last paragraph from the quoted documentation means that the next time you reference the package in the same session, you won't get the error and it will work as normal (until you recompile again).

这篇关于ORA-06508:PL/SQL:找不到正在被调用的程序单元的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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