In packages - subprograms, PL-SQL Programming

In Packages

The Forward declarations also group logically related subprograms in the package. The subprogram specifications go in the package specification, & the subprogram bodies go into the package body, wherever they are invisible to applications. And for this reason, the packages permit you to hide the implementation details. The illustration is as shown below:

CREATE PACKAGE emp_actions AS -- package spec

PROCEDURE hire_employee (emp_id INTGER, name VARCHAR2, ...);

PROCEDURE fire_employee (emp_id INTEGER);

PROCEDURE raise_salary (emp_id INTEGER, amount REAL);

...

END emp_actions;

CREATE PACKAGE BODY emp_actions AS -- package body

PROCEDURE hire_employee (emp_id INTGER, name VARCHAR2, ...) IS

BEGIN

...

INSERT INTO emp VALUES (empno, ename, ...);

END hire_employee;

PROCEDURE fire_employee (emp_id INTEGER) IS

BEGIN

DELETE FROM emp

WHERE empno = emp_id;

END fire_employee;

PROCEDURE raise_salary (emp_id INTEGER, amount REAL) IS

salary REAL;

BEGIN

SELECT sal INTO salary FROM emp

WHERE empno = emp_id;

...

END raise_salary;

...

END emp_actions;

You can define subprograms in the package body without declaring their specifications in the package specification. Though, such subprograms can be called only from inside the package. 

Posted Date: 10/5/2012 5:27:10 AM | Location : United States







Related Discussions:- In packages - subprograms, Assignment Help, Ask Question on In packages - subprograms, Get Answer, Expert's Help, In packages - subprograms Discussions

Write discussion on In packages - subprograms
Your posts are moderated
Related Questions
SQL Operators The PL/SQL uses all the SQL set, comparison, and row operators in the SQL statements. This part briefly describes some of these operators.  1. Comparison Opera

Use the PLS_INTEGER Datatype When you require to declare an integer variable, use the datatype PLS_INTEGER that is the most efficient numeric type. That is as the PLS_INTEGER

Use Serially Reusable Packages To help you to manage the use of memory, the PL/SQL gives the pragma SERIALLY_ REUSABLE that mark some packages as serially reusable . So mark

Use the MASCOT tables CREDITRS, PORDS and PAYMENTS to write SQL queries to solve the following business problems. These tables / data are available to you via the USQ Oracle server

Exception handling In the PL/SQL, a warning or error condition is known as an exception. The Exceptions can be internally defined (by the run-time system) or user defined. The

Parameter Modes: You do not require to specify a parameter mode for the input bind arguments (those used, for illustration, in the WHERE clause) as the mode defaults to IN. Th

Tables within a Table - SQL Figure here is an exact copy of the one in the theory book and as before it is just an alternative way of representing some of the information con

Calling Constructors: The Calls to a constructor are allowed wherever the function calls are allowed. Similarly to the functions, a constructor is called as a section of an ex

Example of NOT EXISTS in SQL Example: Use of NOT EXISTS CREATE ASSERTION Must_be_enrolled_to_take_exam_alternative1 CHECK ( NOT EXISTS (SELECT StudentId, CourseId

Avoid the NOT NULL Constraint In the PL/SQL, using the NOT NULL constraint incur a performance cost. Consider the illustration as shown below: PROCEDURE calc_m IS m NUMB