?
Solved

Identify User Rights on Oracle package

Posted on 2011-09-28
4
Medium Priority
?
281 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 2000 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Configuring and using Oracle Database Gateway for ODBC Introduction First, a brief summary of what a Database Gateway is.  A Gateway is a set of driver agents and configurations that allow an Oracle database to communicate with other platforms…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
This video shows how to Export data from an Oracle database using the Original Export Utility.  The corresponding Import utility, which works the same way is referenced, but not demonstrated.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Suggested Courses

762 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