-
hi,
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???
any help?
thanks
-
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.
Example -->
-- spec part -------
Create or replace package pkg01
procedure a;
function b returns number;
end;
---body part --------
Create or replace package body pkg01
procedure a is
begin
code for a
end;
function b returns number is
begin
function code
return calculated number
end;
procedure c is
begin
a; -- procedure a is called here
code for c
end;
end;
-----------
See
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.
-
hi praff,
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 ??
rgds,
ngwh,
Singapore.
-
Sorry for the late reply.......
Yes you are correct.
Procedure c is invisible outside the body of pkg01.
-
Thanx
Sam
Life is a journey, not a destination!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|