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
Project Description: I have two types of data sources. One that is a list in SharePoint and another that is an access desktop database. The access desktop database is fairly com

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

Recursion The Recursion is a powerful method for simplify the design of the algorithms. Principally, the recursion means the self-reference. In the recursive mathematical serie

Renaming Columns - SQL SQL has no direct counterpart of RENAME. To derive the table on the right in Figure 4.4 from the table on the left, Tutorial D has IS_CALLED RENAME ( St

Parameter and Keyword Description: dynamic_string: This is a string variable, literal, or expression which represents a SQL statement or the PL/SQL block. define_vari

Use Object Types and Collections The Collection types and object types increase your efficiency by allowing for the realistic data modeling. The Complex real-world entities an

First Step at defining type SID in SQL CREATE TYPE SID AS ( C VARCHAR(5) ) ; Explanation: TYPE SID announces that a type named SID is being defined to the syst

Need Database Development with Analysis Tools Project Description: I want a database for large governmental and private data sets on one country that can be simply extended t

Important Distinctions The list of important distinctions are given below: Value versus variable Syntax versus semantics Variable versus variable reference

UTL_FILE: The Package UTL_FILE permits your PL/SQL programs to read & write operating system (OS) text files. It gives a restricted version of the standard OS stream file I/O,