Package Body Assignment Help

Assignment Help: >> Packages - Package Body

Package Body:

It implements the package specification. That is the package body holds the definition of each cursor and subprogram declared in the package specification. Keep in mind in which subprograms defined in a package body are accessible outside the package only if their specifications also appear in the package specification.

To match subprogram specifications and bodies the PL/SQL does a token-by-token comparison of their headers. Then, except for white spaces. The headers must match word for word. Or else, PL/SQL raises an exception, as the subsequent structure displays:

CREATE PACKAGE emp_actions1 AS

...

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

END emp_actions;

CREATE PACKAGE BODY emp_actions1 AS

...

PROCEDURE calc_bonus (date_hired DATE ...) IS

-- parameter declaration raises an exception because 'DATE'

 

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

BEGIN

...

END calc_bonus;

END emp_actions;

The package body can also contain private declarations that define types and items necessary for the internal workings of the package. A scope of that declaration is local to the package body. Thus, the declared types and items are inaccessible except from in the package body. As like a package specification and the declarative category of a package body can hold subprogram bodies.

Subsequent the declarative part of a package body is the optional initialization part that classically contains statements that initialize some of the variables previously declared in the package.

The initialization category of a package plays a minor role since, unlike subprograms, a package cannot be called or passed parameters. As a conclusion, the initialization part of a package is run only once. It is the first time you reference the package is referenced.

Recall that if a specification declares only types, constants, exceptions, and variables, the package body is unnecessary. Therefore, the body can still be used to initialize items declared in the specification.

Examples Private versus Public Items
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd