Advantages of Using Packages
Packages provide an alternative to creating procedures and functions as stand-alone
schema objects, and they offer several benefits.
Modularity and ease of maintenance: You encapsulate logically related programming
structures in a named module. Each package is easy to understand, and the interface
between packages is simple, clear, and well defined.
Easier application design: All you need initially is the interface information in the
package specification. You can code and compile a specification without its body. Then
stored subprograms that reference the package can compile as well. You need not define
the package body fully until you are ready to complete the application.
Hiding information: You decide which constructs are public (visible and accessible) and
which are private (hidden and inaccessible). Declarations in the package specification are
visible and accessible to applications. The package body hides the definition of the private
constructs, so that only the package is affected (not your application or any calling
programs) if the definition changes. This enables you to change the implementation
without having to recompile the calling programs. Also, by hiding implementation details
from users, you protect the integrity of the package.
Added functionality: Packaged public variables and cursors persist for the duration of a
session. Thus, they can be shared by all subprograms that execute in the environment.
They also enable you to maintain data across transactions without having to store it in the
database. Private constructs also persist for the duration of the session but can be accessed
only within the package.
Better performance: When you call a packaged subprogram the first time, the entire
package is loaded into memory. Later calls to related subprograms in the package
therefore require no further disk I/O. Packaged subprograms also stop cascading
dependencies and thus avoid unnecessary compilation.
Overloading: With packages, you can overload procedures and functions, which means
you can create multiple subprograms with the same name in the same package, each taking
parameters of different number or data type.
A blog on SQL , PLSQL , Linux concepts. Interview Questions from different companies. For suggestions and contributions, reach me at sivak36@gmail.com
Featured Post
Will the data from Oracle Database be lost after formatting the system in which it is installed?
So Someone asked me a question, Will the data from Oracle Database be lost after formatting the system in which it is installed? Since the ...
Popular Posts
-
Experience Level - 3- 5 Years SQL Questions: Brief about your experience, skills and projects you worked on. 1.Differenfe betw...
-
Data Dictionary tables/Views contain information about the database and its objects. These are automatically created and maintained by oracl...
-
E 1st round Queries on joins, group by , not in, rank , dense rank, decode, case. (for half an hour to write queries ,given different ta...
-
Select * from a where hiredate+60 < sysdate; (here hiredate is non-unique index, so query scanning index range or full table scanning. ...
-
Generate Sequence of Numbers from 1 to N using SQL Query SELECT LEVEL AS ID FROM DUAL CONNECT BY LEVEL <= 20; ...
-
Stages of Processing SQL Statement: SQL statements pass through several stages during their processing: Parsing Binding Executing O...
-
Introduction Both LAG and LEAD functions have the same usage, as shown below. LAG (value_expression [,offset] [,default]) OVER ([quer...
-
About Temporary Tables : Temporary tables are database tables that hold session specific data Each session can only see and modify its o...
-
Parameter Modes in PLSQL procedures and functions are IN , OUT, IN OUT. The differences are as follows.