package global variable issue

本文探讨了在Oracle数据库中因包头编译导致的ORA-04061等错误的原因及解决方法。通过一个具体的例子展示了当一个会话中修改了包头后,另一个正在使用该包体的会话会出现的状态无效错误。文章提供了短期和长期解决方案,包括避免在生产环境中编译或移除包中的全局变量。
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.
Looking in indexes: http://mirrors.tools.huawei.com/pypi/simple/ Collecting sklearn Downloading http://mirrors.tools.huawei.com/pypi/packages/46/1c/395a83ee7b2d2ad7a05b453872053d41449564477c81dc356f720b16eac4/sklearn-0.0.post12.tar.gz (2.6 kB) Installing build dependencies ... done Getting requirements to build wheel ... error error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> [15 lines of output] The 'sklearn' PyPI package is deprecated, use 'scikit-learn' rather than 'sklearn' for pip commands. Here is how to fix this error in the main use cases: - use 'pip install scikit-learn' rather than 'pip install sklearn' - replace 'sklearn' by 'scikit-learn' in your pip requirements files (requirements.txt, setup.py, setup.cfg, Pipfile, etc ...) - if the 'sklearn' package is used by one of your dependencies, it would be great if you take some time to track which package uses 'sklearn' instead of 'scikit-learn' and report it to their issue tracker - as a last resort, set the environment variable SKLEARN_ALLOW_DEPRECATED_SKLEARN_PACKAGE_INSTALL=True to avoid this error More information is available at https://github.com/scikit-learn/sklearn-pypi-package [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. [notice] A new release of pip is available: 25.1.1 -> 25.3 [notice] To update, run: python.exe -m pip install --upgrade pip error: subprocess-exited-with-error × Getting requirements to build wheel did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. 安装sklearn 报上述错误,该怎么解决
11-06
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值