Package specification, PL-SQL Programming

The 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.

1386_package specification.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/8/2012 1:07:13 AM | Location : United States







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

Write discussion on Package specification
Your posts are moderated
Related Questions
Using EXCEPTION_INIT To handle unnamed internal exceptions, you should use the OTHERS handler or the pragma EXCEPTION_INIT. The pragma is a compiler directive that can be th

Relational Algebra - SQL It describes some operators, that together constitute an algebra that is not only relationally complete but also irreducibly so (very nearly- apart f

UNNEST operator in SQL The inverse operator of GROUP is UNGROUP. SQL has an operator, UNNEST, that can be used for similar purposes, but its method of invocation is somewhat p

Role of Abstraction in pl/sql: The abstraction is a high-level description or model of a real-world entity. The Abstractions keep our daily lives convenient. They help us ca

Row Counterparts of Table Operators SQL does not have counterparts tuple rename, tuple projection, tuple extension, tuple join and tuple compose. To obtain the same effects as

Keyword and Parameter Description: table_reference: This specifies a table or view that should be accessible when you execute the DELETE statement, and for that you must

Based on the EMPLOYEE table created in Assignment #1, write a PL/SQL anonymous block that accepts an employee ID from the user input and finds whether the employee ID is in the EMP

Effects of NULL The numeric variable X, perhaps of type INTEGER, might be assigned NULL. In that case the result of evaluating X + 1 is NULL, and so SET Y = X + 1 assigns NULL

Order of Evaluation When you do not use the parentheses to specify the order of evaluation, the operator precedence determine the order. Now compare the expressions below: NOT

Controlling Cursor Variables You use 3 statements to control the cursor variable: OPEN-FOR, FETCH, & CLOSE. At First, you OPEN a cursor variable FOR a multi-row query. Then, y