I am confused regarding the use of PACKAGE and PACKAGE BODY...
I hv a procedure which i declared and created within a PACKAGE BODY...
do i have to declare it at the PACKAGE as well??
What is the difference for doing and not doing so???
Package has two parts.
Part. 1) Package specification: It is more like procedure/function declaration. Whatever procedure/function you declare here will be visible to users. If you give them
grants they can use procedure/function declared here. In other words, no other procedure/function belonging to this package can be used by user if they are not declared here.
So declare your procedure/function here if you want users to use it (including owner).
You can only declare procdure/function is if you have coded it in Package Body.
Part. 2) Package Body: This is where you write your code.
Body is used to code all your procdure/function. Procdure/function within same body can refer each other but
user can only use coded procdure/function is they are declared in spec.
-- spec part -------
Create or replace package pkg01
function b returns number;
---body part --------
Create or replace package body pkg01
procedure a is
code for a
function b returns number is
return calculated number
procedure c is
a; -- procedure a is called here
code for c
1) Procedure a and fucntion b are visible and usable by users
2) Procedue c is not visible and usable by users but by other pkg01 procedue/function.
Hope this helps,
Have a fun.
Thanks for your enlightenment...but to clear up some doubts here ..
am i right to say from ur example "procedure a" can call "procedure c"
but NOT owner/other users of pkg01 calling "procedure c" ..correct ??
Sorry for the late reply.......
Yes you are correct.
Procedure c is invisible outside the body of pkg01.
Life is a journey, not a destination!
Click Here to Expand Forum to Full Width