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

标签 oracle plsql anonymous

我正在使用 oracle 10g 和 toad 11.5。我正在尝试从匿名 block 调用 api。
如果我在添加 dbms_output.put_line 后重新编译 api然后尝试执行匿名 block ,它显示错误为:

"ORA-06508: PL/SQL: could not find program unit being called".
但是,如果我结束当前 session 并打开一个新 session ,那么匿名 block 将在没有错误的情况下执行。
由于这个问题,每次我对 API 进行更改时,我都会重新连接 session 。
如果可以通过在 toad 或数据库级别进行任何配置来解决此问题,任何人都可以提供帮助。

最佳答案

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

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"

如果是这样,那是因为 your package is stateful :

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.



当您重新编译时,状态会丢失:

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.

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



如果你的包有状态,你就无法避免这种情况。我认为真正需要有状态的包是相当罕见的,所以你应该重新访问你在包中声明的任何东西,但在函数或过程之外,看看它是否真的需要在那个级别。由于您使用的是 10g,因此其中包括常量,而不仅仅是变量和游标。

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

关于oracle - ORA-06508 : PL/SQL: could not find program unit being called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19376440/

相关文章:

sql - PL/SQL FETCH NEXT 或 rownum

java - 单表SQL中如何将2列对应的数据显示到第三列和第四列?

java - 在 Linux Mint 上安装 SQLDeveloper 4 时找不到 bin/java 或不是有效的 JDK

oracle - 什么是 PLSQL 中的 RESULT 关键字?

html - 如何将 <、> 和 & 字符转义为 Oracle PL/SQL 中的 html 实体

ios - UILabel (CALayer) 正在使用大量虚拟内存

c++ - 如果我需要在 header 中使用匿名命名空间怎么办?

sql - 检查后从表中返回值的 PL/SQL 函数

sql - 如何优化在 UPDATE 中追加到 CLOB 的性能?

spring-security - Acegi 安全 : How do i add another GrantedAuthority to Authentication to anonymous user