Using some data dictionary views in PLSQL with ORA-00942 occuring

When you try to use some data dictionary views such as v$, dba_ in a procedure, you may receive an error “ORA-00942: table or view does not exist”. At the same time, you can select the views within SQL under the same schema. I don’t understand the reason, while I find a approach to solve the problem, which you need to grant certain privileges to the user explicitly. [@more@]  

[oracle@oracleserver oracle]$ sqlplus s/s

 

SQL> select value from v$parameter where name='shared_servers';

 

VALUE                                                                          

--------------------------------------------------------------------------------

1                                                                              

 

SQL> create or replace procedure p_test

  2  is

  3  v varchar2(512);

  4  begin

  5  select value into v from v$parameter where name='shared_servers';

  6  end;

  7  /

 

Warning: Procedure created with compilation errors.

 

SQL> show error

Errors for PROCEDURE P_TEST:

 

LINE/COL ERROR                                                                 

-------- -----------------------------------------------------------------     

5/1      PL/SQL: SQL Statement ignored                                         

5/26     PL/SQL: ORA-00942: table or view does not exist                       

 

SQL> exit

 

[oracle@oracleserver oracle]$ sqlplus sys as sysdba

 

SQL> grant select on v_$parameter to s;

 

Grant succeeded.

 

SQL> exit

 

[oracle@oracleserver oracle]$ sqlplus s/s

 

SQL> create or replace procedure p_test

  2  is

  3  v varchar2(512);

  4  begin

  5  select value into v from v$parameter where name='shared_servers';

  6  end;

  7  /

 

Procedure created

 

SQL> exit

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/20294/viewspace-980988/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/20294/viewspace-980988/

### 解决 PL/SQL 中遇到的 Ora-28040 错误 当尝试通过 PL/SQL Developer 连接到 Oracle 12.2 或更新版本时,可能会收到 `ORA-28040: No matching authentication protocol` 的错误消息。此问题通常发生在较旧版本的客户端试图连接到具有更严格安全协议的新版数据库。 #### 修改 SQLNET.ORA 文件配置 为了使低版本的 PL/SQL 客户端能够成功连接至高版本的 Oracle 数据库,可以在服务器侧调整认证协议兼容性的设置。具体操作是在 `$ORACLE_HOME/network/admin/sqlnet.ora` 文件中修改或添加以下参数: ```plaintext SQLNET.ALLOWED_LOGON_VERSION_SERVER=8 ``` 这行配置指示服务器接受来自最低支持版本为 8 的客户端请求[^3]。 对于某些环境而言,可能还需要同步更改客户端上的相应配置项来确保两端的安全策略一致: ```plaintext SQLNET.ALLOWED_LOGON_VERSION_CLIENT=8 ``` 请注意,在生产环境中做出此类变更前应充分评估潜在风险并备份原始文件。 #### 更新 PL/SQL Developer 版本 另一个解决方案是升级使用的 PL/SQL Developer 到最新稳定版本。新版本往往包含了针对不同 Oracle 数据库版本优化过的驱动程序和支持特性,从而减少因不匹配而引发的各种异常情况[^2]。 #### 验证补丁级别 确认所使用的 Oracle Client 和 Server 是否已应用最新的 PSU (Patch Set Update) 补丁包。有时官方发布的修复程序可以直接解决问题而不必改动任何配置文件[^1]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值