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
Map and Order Methods: The values of the scalar datatype like CHAR or REAL have a predefined order that allows them to be compared. While, the instances of an object type has

Overview of control structures According to the structure theorem, any computer program can be written by using the basic control structures as shown in figure below. They can b

Implicit Rollbacks Before execute the INSERT, UPDATE, or DELETE statement, the Oracle marks an implicit savepoint . When the statement fails, the Oracle rolls back to the save

RETURN Statement The RETURN statement instantly completes the execution of a subprogram and returns control to the caller. The Execution then resumes with the statement below t

Avoiding Collection Exceptions   In many cases, if you reference a nonexistent collection element, then PL/SQL raises a predefined exception. Consider the illustration shown b

Overloading: Similar to packaged subprograms, methods of the same type can be overloaded. That is, you can use similar name for various methods if their formal parameters diff

Implicit Cursor Attributes The Implicit cursor attributes returns the information about the execution of an INSERT, DELETE, UPDATE, or SELECT INTO statement. The cursor attribu

Using research notes and Oracle documentation plan and execute an upgrade of an installation of Oracle 10g to Oracle 11g release 1. To do this you must show in screen shots and wri

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

Demonstrate your knowledge of PL/SQL programming by writing and thoroughly testing triggers and stored procedures associated with an e-commerce application that provides security l