Problem in certain rights

I defined a role as:

create the role my_role;

So, I have granted select it on User1. Table1 as:

Grant select on User1.Table1 to my_role:

Then I gave the role as User2:

grant my_role to User2;

I am now able to run the following query, while I'm connected with user 2:

Select * from User1.Table1;

Everything works very well.

Now, I've written a procedure in User2 as

Create or replace procedure User2.someProceduere
(
cur_test on sys_refcursor
)
Begin
Open cur_test
for ' select * from User1.Table1';
End;

While I runt this procedure it produces error message
"Table or view does not exist.

Intrestingly when I live on User1.Table1 of given User2 the procedure itself works, without any error

(Direct right I mean when I give no rights through the "my_role" bolstered
Instead, I write:
Grant select on User1.Table1 to User2 ;)

I want to know the reason? I'm confused, because when I give rights through the role of the procedure does not work
and when I give rights directly to the user the procudue started working.

Published by: Sayyed_Kamran on August 11, 2010 01:40

Right. What is written in detail in the Oracle documentation. Part of:
>
Operation of the roles in PL/SQL blocks
The use of roles in a PL/SQL block depends on if it is an anonymous block, or a block named (stored procedure, function, or trigger), and if it runs with the rights of the author or the rights of the applicant.
Roles used in the appointed with rights to define blocks

All roles are disabled in any PL/SQL block named (stored procedure, function, or trigger) that runs with the rights of the author. Roles are not used to privilege control, and you cannot define roles within the procedure of a DEFINER rights.

The SESSION_ROLES view shows all roles that are currently enabled. If a named PL/SQL block that runs with DEFINER SESSION_ROLES rights issues, the query returns no rows.

http://download.Oracle.com/docs/CD/B28359_01/network.111/B28531/authorization.htm#DBSEG004
>
>
A unit worth AUTHID CURRENT_USER is called a Summoner rights unit, or unit IR. A unit whose value AUTHID is WHAT DEFINE is called a DEFINER rights, or DR. An anonymous block always behaves as a unit of IR. A view or a trigger always behaves as a unit of DR.

The AUTHID of a unit property determines if the unit is IR or DR, and it affects the resolution of names and privilege auditing at run time:

Climate for name resolution is CURRENT_SCHEMA.
Audited privileges are those of the CURRENT_USER and roles enabled.

When a session begins, CURRENT_SCHEMA has the value of the schema owned by SESSION_USER and CURRENT_USER has the same value as SESSION_USER. (To get the current value of CURRENT_SCHEMA, CURRENT_USER or SESSION_USER, use SYS_CONTEXT function, documented in Oracle database SQL language reference).

CURRENT_SCHEMA may be changed during the session with the SQL ALTER SESSION SET CURRENT_SCHEMA. CURRENT_USER cannot be changed programmatically, but it can change when a unit of PL/SQL or view is on, or depilated, thrust the call stack.

Note:
Oracle recommends against ALTER SESSION SET CURRENT_SCHEMA show within a stored PL/SQL unit.

During a server call, when a DR unit's push in the call stack, the database stores the currently activated roles and the current values of CURRENT_USER, CURRENT_SCHEMA. Then it changes CURRENT_USER and CURRENT_SCHEMA DR unit owner and only allows the PUBLIC role. (The stored and new roles and values aren't necessarily different.) When DR unit is popped from the call stack, the database restores the values and roles stored. On the other hand, when an IR unit is pushed or popped, the call, the value of CURRENT_USER, CURRENT_SCHEMA stack, and the roles currently activated does not change.

http://download.Oracle.com/docs/CD/B28359_01/AppDev.111/b28370/subprograms.htm#LNPLS00809

Tags: Database

Similar Questions

Maybe you are looking for

  • Blocking internet HP Pavilion HPE H8 - 1287c:

    Windows crashes and the message with a technician phone number to call.  Message says something about a blue screen and a message to call.  Cannot get rid of the message without turning off the computer.  Message guard reappear. HP Pavilion HPE H8 -

  • a burner

    No burner on media player, it says connect burner and restart the computer, Media Player dowload tried but cannot get it downloaded

  • SGE2010 Ports missing

    Hello I have a number of switches of SGE2010 and I would like to set up the 48 and 24 ports, but I find no reference to them at all in the web interface. Port ads run from 23/1-g1 and g1/25-47. I understand that four SFP ports are shared with the 23,

  • Networking Windows 7 Pro 32-bit or 64 - bit

    My Windows 7 Pro 32 bit computer cannot access the computer of Windows 7 Pro 64 bit.  The convenience store said to ensure that the same router software is installed on both computers.  How can I check this?

  • How to enable OpenGL in Photoshop (Quixel Suite caused the error)

    Hi, I have GTX 970, I used PS with OpenGl very well. And now, I opened QUIXEL Suite, then disabled the OpengGl PS and I can't turn it back on. I rebooted my computer, I can't still turn on Opengl. Could you have the solution?