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
Updating a Variable Assignment of an attribute value in a variable of a structured type Synatx: SET SN.C = 'S2'; As in Example the entire statement is equivalent to a

PRIMARY KEY: PRIMARY KEY  indicates that the table is subject to a key constraint, in this case declaring that no two rows in the table assigned to ENROLMENT can ever have the

Expressions   An expression is a randomly complex combination of the constants, variables, literals, operators, & function calls. The simplest expression is the single variabl

set serveroutput on declare a number(5); b number(5); c number(5); begin a:=&a; b:=&b; c:=a/b; dbms_output.put_line(c); exception when zero_divide then d

At times, customers make mistakes in submitting their orders and call to cancel the order. Brewbean’s wants to create a trigger that automatically updates the stock level of all pr

Number Types The Number types permit you to store the numeric data (real numbers, integers, and floating-point numbers), show quantities, and do computations. BINARY_INTEG

Pass the nulls to a dynamic SQL: Passing Nulls: Assume that you want to pass the nulls to a dynamic SQL statement. For illustration, you may write the EXECUTE IMMEDIATE

Using RENAME in combination with JOIN - SQL Example gives pairs of ids of students having the same name, by joining two renamings of IS_CALLED. Example gives an equivalent ex

Bulk Fetching The illustration below shows that you can bulk-fetch from a cursor into one or more collections: DECLARE TYPE NameTab IS TABLE OF emp.ename%TYPE; TYPE S

Develop Data Business Intelligence Project Project Description: We are linking our Microsoft SQL Database to GoodData Business Intelligence. We are seeking somebody who has e