Can anyone please explain me the difference between public items inside the package
and private items inside package
?
What type of deceleration is this :
create or replace package BOOK_MANAGEMENT
as
function OVERDUE_CHARGES(aName IN VARCHAR2) return NUMBER;
procedure NEW_BOOK (aTitle IN VARCHAR2,
aPublisher IN VARCHAR2, aCategoryName IN VARCHAR2);
end BOOK_MANAGEMENT;
Public and Private Items in a package
Public is a keyword denoting that that particular item can be accessed outside the package.
Private means that the item will only be used internally in the package.
Example
Now the procedure and function here are public and accessible to the outside world.
However now the body for example
Note above the number of books is private and isn't shown to the user. It is however (assumed to be) necessary to implement the methods
Similarly you could have private functions also
How to make number_of_books public
Note - in-line functions in a package cannot be 'private' because their definition must be in the package header to determine their 'purity'. You cannot issue PRAGMA RESTRICT REFERENCES in a package body. I believe this to be a bug (using Oracle 11.2.0.4).