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
%FOUND Subsequent to a cursor or cursor variable is opened but before the first fetch, the %FOUND yields NULL. Afterward, it yields TRUE when the last fetch returned a row, or

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

Overloading The PL/SQL overloads the subprogram names. That is, you can use similar name for few different subprograms as long as their formal parameters differ in the number

Constants and Variables:   You can declare the constants and variables in the declarative section of any PL/SQL subprogram, block, or package. The Declarations allot the stor

I want someone to write a TSQL function that returns the name of the ODBC DSN. I will use the queries below, to get information about the connection, but none of these return th

ROWID The ROWID returns the rowid (binary address) of a row in the database table. You can use the variables of the type UROWID to store rowids in a readable format. In the il

Initializing Objects: Till you initialize an object by calling the constructor for its object type, the object is automatically null. That is, the object itself is null, not me

IN Operator The operator IN tests the set membership. This means "equal to any member of." The set may have nulls, but they are ignored. For illustration, the statement below do

Using RENAME in combination with JOIN - SQL Example gives pairs of ids of students having the same name, by joining two renamings of IS_CALLED. Example gives an equivalent ex

Using EXISTS The EXISTS(n) returns TRUE if the nth element in a collection exist. Or else, EXISTS(n) returns FALSE. Primarily, you use EXISTS with DELETE to maintain the spars