Package body in pl/sql, PL-SQL Programming

Package Body:

The package specification is implemented by the package body. That is, the package body has the definition of every cursor and the subprogram declared in the package specification. Remember that the subprograms defined in the package body are available outside the package only if their specifications also show in the package specification. To match the subprogram specifications and bodies, the PL/SQL does a token-by-token comparison of their headers. Therefore, except for white space, the headers should match word for word. Or else, the PL/SQL raises an exception, as the illustration below shows:

 

CREATE PACKAGE emp_actions AS

...

PROCEDURE calc_bonus (date_hired emp.hiredate%TYPE, ...);

END emp_actions;

CREATE PACKAGE BODY emp_actions AS

...

PROCEDURE calc_bunus (date_hired DATE, ...) IS

-- parameter declaration raises an exception as 'DATE'

-- does not match 'emp.hiredate%TYPE' word for word

BEGIN ... END;

END emp_actions;

The package body can also contain the private declarations that define the types and items essential for the internal workings of the package. The scopes of these declarations are local to the package body. And hence, the declared types and items are unapproachable except from within the package body. Dissimilar the package specification, the declarative section of a package body can have the subprogram bodies.

The declarative section below of the package body is the optional initialization sections that typically hold the statements that initialize some of the variables formerly declared in the package.

The initialization section of the package plays a minor role as, dissimilar subprograms; the package cannot be called or passed parameters. As an outcome, the initialization section of the package is only run once, that is the first time you reference the package. Keep in mind that, if a package specification declares only constants, types, variables, exceptions, and call specifications, the package body is needless. Though, the body can still be used to initialize the items declared in the package specification.

Posted Date: 10/6/2012 7:42:25 AM | Location : United States







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

Write discussion on Package body in pl/sql
Your posts are moderated
Related Questions
Varrays versus Nested Tables The Nested tables are differing from varrays in the following ways: 1)  Varrays have a maximum size, while nested tables do not. 2)  Varrays are

CURRVAL and NEXTVAL The series is a schema object which generates the sequential numbers. Whenever you form a sequence, you can specify its primary value and an increment. T

Use Native Dynamic SQL A few programs (a normal-purpose report writer for illustration) should build and process a variety of SQL statements at run time. Therefore, their full

Project Description: I am looking to change FullCalendar to add/delete sql server data when events are removed or dropped from Calendar. Events should only be included by dra

Table Represents an Extension - SQL It describes how each tuple in a relation represents a true instantiation of some predicate and each true instantiation is represented by s

%ROWCOUNT The %ROWCOUNT yields the number of rows affected by the INSERT, UPDATE, or DELETE statement, or returned by a SELECT INTO statement. The %ROWCOUNT yields zero when a

THEO R Y OF ETERNITY OF LIFE (PRAYER - 1880) - The theory of eternity of life, also called the steady-state theory , states that life has ever been in existence as at presen

query to Find the account numbers of all customers whose balance is more than 10,000 $

User-Defined Exceptions The PL/SQL defines the exceptions of your own. Dissimilar to the predefined exceptions, the user-defined exceptions should be declared and should be rai

Relational Operators and Logical Operators It prepares the ground for subsequent sections in which each specific relational operator is paired with its logical counterpart, su