Monday 17 October 2011

PackageStored Procedure (Difference)

A Package is a database object that groups logically related PL/SQL types, objects and subprograms. Packages usually have 2 parts - specification & body. The specification is the interface to your applications; it declares the types, variables, constants, exceptions, cursors and subprograms available for use. The Body fully defines cursors and subprograms, and so implements the Specification.
Unlike subprograms, packages cannot be called, passed parameters, or nested.
A Package might include a collection of procedures. Once written, your general-purpose package is compiled, and then stored in an ORACLE database, where, like a library unit, its contents can be shared by many applications.

Advantages of Packages:
• Modularity
• Easier Application design: Initially once the Specification has been compiled, the Body need not be fully defined until one is ready to complete the application.
• Information hiding: Certain procedures can be made as Public (visible and accessible) and others as Private (hidden and inaccessible).
• Added Functionality: Packaged public variables and cursors persist for the duration of a session. So, they can be shared by all procedures that execute in the environment. Also, they allow you to maintain data across transactions without having to store it in the database.
• Better Performance: When you call a package for the first time, the whole package is loaded into memory. Therefore, subsequent calls to related procedures in the package require no disk I/O.
Procedure:
A Procedure is a subprogram that performs a specific action.

No comments:

Post a Comment