Solved

GRANT  EXECUTE on Package body??

Posted on 2010-08-30
11
6,516 Views
Last Modified: 2012-05-10
Hi,
can you please somebody send me syntax for GRANT Execute on Package body? i did not see package body in SQL developer even I  ran the " GRANT EXECUTE ON schema.xyz_pkg to  some_user;" i do see the package specification but not package body. i am using SQL developer. Did i am missing anything in the systax??
0
Comment
Question by:husseink
  • 3
  • 3
  • 2
  • +3
11 Comments
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 33561562
>>Did i am missing anything in the systax??


Nope.  You grant execute on the package.  That's it.
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 33561566
connect as the owner/schema to grant the permissions. not "everybody" can grant permissions.
0
 

Author Comment

by:husseink
ID: 33561647
i connected as a schema owner and executed the above syntax. still the user don't see the packagebody...
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 33561667
in the sql developer, you might need to "refresh" in the package folder to see the new permissions.
though EXECUTE permissions does not give you permissions to see the package body code, if I remember correctly ...
0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 33561671
Unless there is a synonym they need to fully qualify it with schema.xyz_pkg.

If the user logs in to sql*plus what do they see when the do the following:
SQL> describe schema.xyz_pkg



0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:husseink
ID: 33563837
i refreshed but still package bodies folder does not have anything.
when i say describe schema.xyz_pkg , i see only package specification....
0
 
LVL 7

Expert Comment

by:sumit2906
ID: 33564140
describe will show only signature of packages procs.
if you want to make sure that the package is avaialble, query all_source.
0
 
LVL 1

Expert Comment

by:saxtonj
ID: 33564763
try

SELECT text
FROM all_source
WHERE owner = <schema_owner>
AND   NAME = <package_name>
AND TYPE = 'PACKAGE BODY'

or get an IDE like TOAD, SQL Developer, or PLSQL Developer
0
 
LVL 13

Accepted Solution

by:
riazpk earned 50 total points
ID: 33565379
You either need to grant 'create any procedure' or 'select on dba_source' to the user whom you want to be able to see the source code of package body. Here is the test case to prove this:
 

SQL> ed

Wrote file afiedt.buf



  1  create or replace package pkg_test as

  2  procedure p_test;

  3* end;

SQL> /



Package created.



SQL> ed

Wrote file afiedt.buf



  1  create or replace package body pkg_test as

  2  procedure p_test is

  3  begin

  4    null;

  5  end;

  6* end;

SQL> /



Package body created.



SQL> create user test identified by test;



User created.



SQL> grant execute on pkg_test to test;



Grant succeeded.



SQL> conn test/test@test-server

ERROR:

ORA-01045: user TEST lacks CREATE SESSION privilege; logon denied





Warning: You are no longer connected to ORACLE.

SQL> conn riaz@test-server

Enter password: ********

Connected.

SQL> grant create session to test;



Grant succeeded.



SQL> conn test/test@test-server

Connected.

SQL> desc riaz.pkg_test

PROCEDURE P_TEST



SQL> ed

Wrote file afiedt.buf



  1* SELECT distinct type from all_source where name='PKG_TEST'

SQL> /



TYPE

------------

PACKAGE



--So the user can only see package not package body. This is your situation.



SQL> conn riaz@test-server

Enter password: ********

Connected.

SQL> grant create any procedure to test;



Grant succeeded.



SQL> conn test/test@test-server

Connected.

SQL> SELECT distinct type from all_source where name='PKG_TEST';



TYPE

------------

PACKAGE

PACKAGE BODY



--User can see package body as well now



SQL> conn riaz@test-server

Enter password: ********

Connected.

SQL> revoke create any procedure from test;



Revoke succeeded.



SQL> conn sys@test-server as sysdba

Enter password: ***********

Connected.

SQL> grant select on dba_source to test;



Grant succeeded.



SQL> conn test/test@test-server

Connected.

SQL> SELECT distinct type from all_source where name='PKG_TEST';



TYPE

------------

PACKAGE



SQL> ed

Wrote file afiedt.buf



  1* SELECT distinct type from dba_source where name='PKG_TEST'

SQL> /



TYPE

------------

PACKAGE

PACKAGE BODY



--User can see package body as well now. With this method you need to query dba_source.

Open in new window

0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 33566514
>>describe schema.xyz_pkg , i see only package specification....

What are you wanting to do here?  

You do not grant execute on a package body.  You grant execute on the package itself and users can execute any exposed procedure or function in the package.

If you are wanting to actually see the code then use the queries above to select against dba_source.

Please explain exactly what you are wanting to do.
0
 

Author Comment

by:husseink
ID: 33570259
Thanks riazpk: Thanks for all ur anaswers.  Problem is when the user log on using SQL developer he is not able to see the package body . he only sees package spec.

As per riazpk comment: i did   "grant create any procedure to test;".  I grant this on the my user. now user can able to see the package body using SQL developer.

Thanks for all once again....
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Single ERP VS muttiple Application or Systems 6 62
Dataware house query tuning 9 64
VB.Net - CSV to Oracle table 4 52
Concat multi row values of a field in oracle 6 52
Subquery in Oracle: Sub queries are one of advance queries in oracle. Types of advance queries: •      Sub Queries •      Hierarchical Queries •      Set Operators Sub queries are know as the query called from another query or another subquery. It can …
How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
This video shows setup options and the basic steps and syntax for duplicating (cloning) a database from one instance to another. Examples are given for duplicating to the same machine and to different machines
This video shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

910 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now