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:

FUNCTION fac (n INTEGER) RETURN INTEGER; -- returns n!

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

CREATE PACKAGE trans_data AS

TYPE TimeRec IS RECORD (

minutes SMALLINT,

hours SMALLINT);

TYPE TransRec IS RECORD (

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
ORIGIN OF EARTH - BIG-BAN G HYPOTHESIS - Origin of life is linked to origin of earth. Cosmos, the Universe originated 10-20 billion years ago by Big Bang (thermonu

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

Task 2 [12 marks] Write the package body for the following package specification (the detailed description of each function and procedure is provided in the appendix below). Place

Question: (a) The objective of query optimization is to choose the most efficient strategy for implementing a given relational query, thereby improving the system performance. On

Running the PL/SQL Wrapper To run the PL/SQL Wrapper, go through the wrap command at your operating system prompt by using the syntax as shown: wrap iname=input_file [oname=

Using ROLLBACK The ROLLBACK statements end the present transaction and undo any change made during the transaction. The Rolling back is helpful for two reasons. Firstly, if yo

LAWS / RULES - Dollo's Law                     :           Living organisms do exhibit evolutionary irreversibility or evolution is irreversible. Williston's Law

Using DELETE This process has three forms. The DELETE removes all elements from the collection. DELETE(n) removes the nth element from the nested table. When n is null, then D

Delimiters A delimiter is a simple or compound symbol which has a special meaning to PL/SQL. For example, you use delimiters to symbolize an arithmetic operation like additio

Creating a SQL file 1. Open a new file in Notepad++ and save it to the location c:\mysql\bin, with the name lab8script.sql (the file extension should be .sql ). Add a MySQL co