oracle查看directory使用权,请教关于dbms_session的使用权限问题

Problem Description:

~~~~~~~~~~~~~~~~~~~~

You created context and are trying to add additional attributes there using

DBMS_SESSION.SET_CONTEXT procedure are are receiving:

ERROR at line 1:

ORA-01031: insufficient privileges

ORA-06512: at "SYS.DBMS_SESSION", line 55

ORA-06512: at line 1

For example in SQL*Plus you did:

SQL> CREATE CONTEXT m_context USING sec_user.p_context;

where

m_context is the context name (namespace)

p_context is the package in the sec_user schema.

Then you issued command:

SQL> EXECUTE DBMS_SESSION.SET_CONTEXT('m_context','attr1','Hello');

OR

SQL> begin

2  DBMS_SESSION.SET_CONTEXT('m_context','attr1','Hello');

3  end;

4  /

where

m_context is the context name (namespace)

attr1     is the name of an attribute you're adding

Hello     is the value for this attribute

As a result you receive the above errors.

Solution Description:

~~~~~~~~~~~~~~~~~~~~~

To solve the problem create additional procedure.

(for example set_additional_attr) in the p_context package and put

DBMS_SESSION.SET_CONTEXT('m_context','attr1','Hello');

into this procedure.

Then from SQL*Plus run

SQL> EXECUTE sec_user.p_context.set_additional_attr;

Now attribute is set.

Testcase:

~~~~~~~~~

connect system/manager;

create user sec_user identified by sec_user;

grant connect, resource, dba to sec_user;

connect sec_user/sec_user;

create or replace package p_context as

procedure set_additional_attr;

end p_context;

/

create or replace package body p_context as

procedure set_additional_attr is

begin

dbms_session.set_context( 'm_context', 'attr1', 'Hello' );

end;

end p_context;

/

connect system/manager;

create context m_context using sec_user.p_context;

-- This statement will fail

execute dbms_session.set_context( 'm_context', 'attr1', 'Hello' );

ERROR at line 1:

ORA-01031: insufficient privileges

ORA-06512: at "SYS.DBMS_SESSION", line 55

ORA-06512: at line 1

-- set attribute by running this command

execute sec_user.p_context.set_additional_attr;

-- check if attribute was set

select sys_context( 'm_context', 'attr1' ) from dual;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值