Solved

Identify User Rights on Oracle package

Posted on 2011-09-28
4
276 Views
Last Modified: 2012-05-12
Create or replace package pkgx authid definer
is
    executionuserrights varchar2(100) : = xxxxxxx ; -- I need the definer user name to be captured

end pkgx;



Create or replace package pkgy authid current_user
is
    executionuserrights varchar2(100) : = User; -- This captures the user name of the invoker

end pkgx;



I need something like


If userrights = 'Definer' then
    ExecutionRights := owner of the package;

elsif userrights = 'Current_user' then
    ExecutionRights := User;
end if;

0
Comment
Question by:vishali_vishu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 36717621
>>userrights = 'Definer'

I'm not understanding the question.  What do you want to capture if not who is executing the package?
0
 
LVL 74

Expert Comment

by:sdstuber
ID: 36717669
select distinct authid from user_procedures where object_name = 'YOUR_PACKAGE'

however,  you can't change it from within the package if that's what you're trying to do

you'll have to recompile it
0
 
LVL 1

Author Comment

by:vishali_vishu
ID: 36717675
I wanted the schema name to be captured to a variable while executing a package.

if package is set to definer rights

 variable = definer user name;

if package is set to current_user rights

variable= invoker user name;




0
 
LVL 74

Accepted Solution

by:
sdstuber earned 500 total points
ID: 36717726
ah, ok that's much easier

no if necessary, just use the USERENV context

variable := sys_context('userenv','CURRENT_USER');
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article started out as an Experts-Exchange question, which then grew into a quick tip to go along with an IOUG presentation for the Collaborate confernce and then later grew again into a full blown article with expanded functionality and legacy…
How to Unravel a Tricky Query Introduction If you browse through the Oracle zones or any of the other database-related zones you'll come across some complicated solutions and sometimes you'll just have to wonder how anyone came up with them.  …
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to copy an entire tablespace from one database to another database using Transportable Tablespace functionality.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question