Package body, PL-SQL Programming

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



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

END emp_actions;



PROCEDURE calc_bunus (date_hired DATE, ...) IS

-- parameter declaration raises an exception as 'DATE'

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


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/8/2012 1:08:52 AM | Location : United States

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

Write discussion on Package body
Your posts are moderated
Related Questions
Declaring Objects: You can use the object types wherever built-in types like CHAR or NUMBER can be used. In the block below, you can declare object r of type Rational. Then, yo

Difference between 9i & 10G When Oracle releases any new databases then it are having some discrepancy with them. But 10G is having much difference than oracle 9i has. Oracle

Advantages of Invoker Rights The Invoker-rights routines centralize the data retrieval. They are particularly helpful in applications which store data in various schemas. In su

Problem: (a) Define the following terms: (i) data mining. (ii) OLAP. (b) Differentiate between snowflake schema and star schema. Support your answer with appropriate

Write a pl/sql block that declares and uses cursors with parameters. In a loop, use a cursor to retrieve the department number and the department name from the departments table

Challenge 1 You are required to do the project and write a test plan for it. Demo 4 is a check writer program for employees. In it, the user enters all information about the

Question: (a) The objective of query optimization is to choose the most efficient strategy for implementing a given relational query, thereby improving the system performance. On

Disjunction (OR, ∨) Again we have nine rows instead of just four and again, when unknown is not involved, the rows are as for 2VL. Also, when anything is paired with true, t

Operators on Tables and Rows Row Extraction TUPLE FROM r, SQL has row subqueries. These are just like scalar subqueries except that they may specify more than one column.

Sequential Control Dissimilar to the IF and LOOP statements, the GOTO and NULL statements are not important to the PL/SQL programming. The configuration of PL/SQL is such that th