Identify User Rights on Oracle package

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;

LVL 1
vishali_vishuAsked:
Who is Participating?
 
sdstuberConnect With a Mentor Commented:
ah, ok that's much easier

no if necessary, just use the USERENV context

variable := sys_context('userenv','CURRENT_USER');
0
 
slightwv (䄆 Netminder) Commented:
>>userrights = 'Definer'

I'm not understanding the question.  What do you want to capture if not who is executing the package?
0
 
sdstuberCommented:
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
 
vishali_vishuAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.