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
%ROWTYPE: This attribute gives a record type which represents a row in the database table or a row fetched from a formerly declared cursor. The Fields in the record and corresp

Parameter Default Values As the illustration below shows, you can initialize the IN parameters to the default values. In that way, you can pass various numbers of actual par

Redeclaring Predefined Exceptions Keep in mind that, the PL/SQL declares predefined exceptions globally in the package STANDARD; Therefore you need not declare them yourself.

to write a heap sort program usin pl-sql

How Bulk Binds Improve Performance The assigning of values to the PL/SQL variables in SQL statements is known as binding. The binding of the whole collection at once is know

Restriction and AND - SQL Restriction is available via the WHERE operator, and so it is in SQL. However, by Example showing how a certain simple restriction can be expressed u

First Step at defining type SID in SQL CREATE TYPE SID AS ( C VARCHAR(5) ) ; Explanation: TYPE SID announces that a type named SID is being defined to the syst

Assignment Source Not a Literal - Variable Syntax: SET SN = SID (SUBSTRING (SN.C FROM 1 FOR 1)||'5');

Great Plains (Microsoft Dynamics) Purchases Report Project Description: I want to build a purchases report that matches the General Ledger. presently, when I join the PM20

Use of COUNT in SQL It describes and discusses various general methods of expressing constraints, eventually noting that support for "=" with relation operands is sufficient f