ORA-04068: existing state of packages has been discarded

2023-11-22 01:58

本文主要是介绍ORA-04068: existing state of packages has been discarded,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

一.版本信息

操作系统版本:

AIX 6100

数据库版本:

11.2.0.3(psu5)

 

二.错误描述

#因为该错误有很多可能的原因,所以此处描述场景的时候需要详细点

该错误是我在解决oracle "Doc ID 1413756.1"所描述错误时触发的。(具体可以见我的前面的博客)

1. 按照"Doc ID 1413756.1"提供的临时解决方案,我分别执行了如下命令

-- Login as sys user.
SQL> sqlplus / as sysdba
-- From the sqlplus execute the following:
-- Drop the DBSNMP user by executing catnsnmp.sql script.
SQL> @$ORACLE_HOME/rdbms/admin/catnsnmp.sql
-- Create the DBSNMP user by executing catsnmp.sql
SQL> @$ORACLE_HOME/rdbms/admin/catsnmp.sql

#删除时报了某角色不存在,重建时报了一些object已存。没有大的问题。

2. 为了确保没有问题我再次重复了上面删除和重建DBSNMP用户的命令(在同一个会话中)

#删除用户时,跟首次执行一致,但是在重建用户时我看到了如下报错:

Package body created.
Package body created.
declare
*
ERROR at line 1:
ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package "DBSNMP.BSLN" has been invalidated
ORA-04065: not executed, altered or dropped package "DBSNMP.BSLN"
ORA-06508: PL/SQL: could not find program unit being called: "DBSNMP.BSLN"
ORA-06512: at line 18
PL/SQL procedure successfully completed.

#从报错中其实我们已经可以看出一些端倪出来,报错说package的state(申明)已经无效,然后导致了后面的错误

 

三. 错误原因及解决方案

查找我们的老帮手MOS发现了"Doc ID 1161225.1"这篇NOTE可以解释我遇到的问题,我贴出了其中一部分:

When a package is compiled, altered or an object on which the package depends is altered, all copies of that package in the shared pool are flagged as invalid. 
The next invocation of the package from another database session ( even if it is the same username) sees that this flag is set and goes to get a new copy.   <span style="color:#ff0000;">If the package has package state, i.e. it has one or more package variables that would normally persist across calls to the package within the same session, then ORA-4068 error is raised to indicate to the caller that that package state (i.e the current values of those package variables)  has been lost</span>.  When the ORA-4068 is raised, ORACLE will throw away all existing instantiations of the package.  When the package (more properly, the subprogram referring to the package) is re-executed, ORACLE will re-instantiate the package automatically (If possible), which will typically succeed, and re-execution of the subprogram will succeed.
The mechanism is not sensitive enough to check whether the calling session actually referred to any of the package variables so you always get the error in these situations if the package you are calling has package variables defined.  <span style="color:#ff0000;">This is quite common therefore if your program calls a system level package (typically beginning DBMS_ or  UTL_)  that has been recompiled, as the majority of them have at least one package variable defined.</span>

#大概就是说一个程序包被编译或者alert或者包所依赖的对象被alert,那么shared pool(注意此处是shared pool )中该包的copies都会标记为失效状态。

其他的会话再次调用该报的时候发现失效标记后,会去获取新的copy。

  如果这个包有申明的话,比如这个包申明了变量,那么我们在同一个会话中再次调用这个变动过的包,就会报ORA-4068这个错误,向调用者表明该包的申明已经失效。(这就是我第二次执行重建DBSNMP用户报错的原因)。

#这个报错我们可以看错是一个警告,我们无需处理,再次调用就没有问题了。

 

四. 相关知识

#上面我们只列出了我工作中碰到的情况,还有一些其他情况会触发该报错

"Doc ID 106206.1"中列出了一些常见的场景,我们也可以在MOS中直接搜该报错查看符合自己问题的note

 


 

 

这篇关于ORA-04068: existing state of packages has been discarded的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/406657

相关文章

状态模式state

学习笔记,原文链接 https://refactoringguru.cn/design-patterns/state 在一个对象的内部状态变化时改变其行为, 使其看上去就像改变了自身所属的类一样。 在状态模式中,player.getState()获取的是player的当前状态,通常是一个实现了状态接口的对象。 onPlay()是状态模式中定义的一个方法,不同状态下(例如“正在播放”、“暂停

ora-01017 ora-02063 database link,oracle11.2g通过dblink连接oracle11.2g

错误图示: 问题解决 All database links, whether public or private, need username/password of the remote/target database. Public db links are accessible by all accounts on the local database, while private

ORA-25150:不允许对区参数执行ALTERING

在用PL/SQL工具修改表存储报错: 百度一下找到原因: 表空间使用本地管理,其中的表不能修改NEXT MAXEXTENTS和PCTINCREASE参数 使用数据自动管理的表空间,其中的表可以修改NEXT MAXEXTENTS和PCTINCREASE参数

ORA-01861:文字与格式字符串不匹配

select t.*, t.rowid from log_jk_dtl t; insert into log_jk_dtl (rq,zy,kssj,jssj,memo)  values (to_date(sysdate,'yyyy-mm-dd'),'插入供应商', to_char(sysdate,'hh24:mi:ss'),to_char(sysdate,'hh24:mi:ss'),'备注'

利用PL/SQL工具连接Oracle数据库的时候,报错:ORA-12638: 身份证明检索失败的解决办法

找到相对应的安装目录:比如:E:\oracle\product\10.2.0\client_1\NETWORK\ADMIN 在里面找到:SQLNET.AUTHENTICATION_SERVICES= (NTS) 将其更改为:SQLNET.AUTHENTICATION_SERVICES= (BEQ,NONE) 或者注释掉:#SQLNET.AUTHENTICATION_SERVICES= (N

ORA-00600 [1880]

-----环境信息 [oracle@trsen02 bdump]$ uname -a Linux trsen02.yto.com 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:39 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux SQL> select * from v$version; BANNER ----

ORA-31626/ORA-31638/ORA-39077/ORA-6502

导数据遇到ORA-31626/ORA-31638/ORA-39077/ORA-6502 报错信息如下: [oracle@vm010148 ~]$ expdp system/oracle directory=dir dumpfile=full.dmp logfile=full.log Export: Release 11.2.0.3.0 - Production on Sun Sep

ORA-00600 [504]

ALERT日志: Wed Sep 10 09:00:53 2014 Errors in file /u01/app/oracle/diag/rdbms/trsendb/trsendb2/trace/trsendb2_ora_40371414.trc  (incident=821340): ORA-00600: internal error code, arguments: [504],

【oracle sql错误】ORA-01795: 列表中的最大表达式数为 1000

select SOURCE_ID,FILTER_TEXT from TEXT_CENTER where SOURCE_ID in() in后面的括号里的数目超过1000条。 问题描述: SQL进行IN查询时,IN中的数据量不能超过1000条。 解决办法: 拆分:id in (1,2,3,4,5,,,,999) or id in(1000,1001,1002,1003,1004,,,,,,