Database Interaction with PL/SQL, Named Notations, Storing Procedures and Functions - PACKAGE and PACKAGE BODY
(Page 5 of 5 )
A package is a single unit containing several stored sub-programs. Even a package itself gets stored inside the database (along with all of its sub-programs). Basically any package in Oracle has two parts, namely the package specification and the package body.
The package specification contains the definition or specification of all the elements in the package that may be referenced outside of the package. These are called the public elements of the package. Like the module, the package specification contains all the code that is needed for a developer to understand how to call the objects in the package. A developer should never have to examine the code behind the specification (which is the body) in order to understand how to use and benefit from the package. The package specification does not contain any executable statements or exception handlers. A specification only specifies, or declares, those objects in the package that are public -- that is, visible outside of the package and callable by other programs.
The body of the package contains all the code behind the package specification: the implementation of the modules, cursors, and other objects. The body may also contain elements that do not appear in the specification. These are called private elements of the package. A private element cannot be referenced outside of the package, since it does not appear in the specification.
The body of the package resembles a standalone module's declaration section. It contains both declarations of variables and the definitions of all package modules. The package body may also contain an execution section, which is called the initialization section because it is only run once, to initialize the package.
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |