package global variable issue

ORA-04061: existing state of has been invalidated
.session 1:

Session_1>create package pck is
2 a number;
3 procedure print_a;
4 end pck;
5 /

Package created.

Session_1>create or replace package body pck is
2 procedure print_a is
3 begin
4 dbms_output.put_line(a);
5 end print_a;
6 begin
7 a:= 9;
8 end;
9 /

Package body created.

Session_1>exec pck.print_a;
9

PL/SQL procedure successfully completed.

session 2:
Session_2> exec pck.print_a;
9

PL/SQL procedure successfully completed.

back to session 1, compiling the package header:
Session_1>alter package pck compile;

Package altered.

getting the error in session 2:
Session_2> exec pck.print_a;
BEGIN pck.print_a; END;

*
ERROR at line 1:
ORA-04068: existing state of packages has been discarded
ORA-04061: existing state of package body "HR_APP.PCK" has been invalidated
ORA-04065: not executed, altered or dropped package body "HR_APP.PCK"
ORA-06508: PL/SQL: could not find program unit being called: "HR_APP.PCK"
ORA-06512: at line 1

solution:
a. don't compile at the production environment, or at least not the parts of the package that contain the global variable
b. long term solution - remove global variable from package.
Amiel.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值