Package specification in pl/sql , PL-SQL Programming

Package Specification

The package specifications contain the public declarations. The scopes of these declarations are local to your database representation and global to the package. Therefore, the declared items are available from your application and from anyplace in the package. The figure describes the scoping.

1759_package defination in pl-sql.png

Figure: Package Scope

The specification lists the package resources accessible to the applications. All the information that your application require to use the resources is in the specification. For illustration, the declaration below shows that the function named the fac takes one argument of the type INTEGER and returns a value of type INTEGER:


That is all the information you require to call the function. You do not require to consider its underlying implementation (whether it is recursive or iterative for illustration). The subprograms and cursors only have an underlying implementation or definition. Therefore, if a specification declares only the constants, types, variables, exceptions, and call specifications, the package body is unessential. Consider the bodiless package which is as shown below: 

-- a bodiless package



minutes SMALLINT,

hours SMALLINT);


category VARCHAR2,

account INTEGER,

amount REAL,

time_of TimeRec);

minimum_balance CONSTANT REAL := 10.00;

number_processed INTEGER;

insufficient_funds EXCEPTION;

END trans_data;

The package trans_data requires no body as the constants, types, variables, and the exceptions do not have an underlying implementation. These packages define the global variables-usable by the subprograms and database triggers-that persist throughout a session.


Posted Date: 10/6/2012 7:41:18 AM | Location : United States

Related Discussions:- Package specification in pl/sql , Assignment Help, Ask Question on Package specification in pl/sql , Get Answer, Expert's Help, Package specification in pl/sql Discussions

Write discussion on Package specification in pl/sql
Your posts are moderated
Related Questions
What are 3 good practices of modeling and/or implementing data warehouses?

Difference between 9i & 10G When Oracle releases any new databases then it are having some discrepancy with them. But 10G is having much difference than oracle 9i has. Oracle

Using Aliases The Select-list items fetched from a cursor related with the %ROWTYPE should have simple names or, if they are expressions, should have aliases. In the example bel

How Calls Are Resolved? The figure shows that how the PL/SQL compiler resolves the subprogram calls. When the compiler encounters the procedure or function call, it tries to di

Structure of an Object Type: Similar to package, an object type has 2 parts: the specification and the body. The specification is the interface to your applications; it declar

Components of an Object Type: An object type encapsulates the operations and data. Therefore, you can declare the methods and attributes in an object type specification, but no

Advantages of Packages The benefits of the Packages are as shown below: Modularity The Packages encapsulate logically associated items, types, and subprograms in the

Using EXTEND To enlarge the size of a collection, use EXTEND. This process has 3 forms. The EXTEND appends one null element to a collection. And the EXTEND(n) appends n null e

Defining Autonomous Transactions To define an autonomous transaction, you use the pragma (compiler directive) AUTONOMOUS_TRANSACTION. The pragma instructs the PL/SQL compiler

Disjunction (OR, ∨) Again we have nine rows instead of just four and again, when unknown is not involved, the rows are as for 2VL. Also, when anything is paired with true, t