In packages - subprograms, PL-SQL Programming

Assignment Help:

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. 


Related Discussions:- In packages - subprograms

CURSOR, #quesWrite a cursor to open an employee database and fetch the empl...

#quesWrite a cursor to open an employee database and fetch the employee record whose age is greater than 45.tion..

Delimiters, Delimiters A delimiter is a simple or compound symbol whi...

Delimiters A delimiter is a simple or compound symbol which has a special meaning to PL/SQL. For example, you use delimiters to symbolize an arithmetic operation like additio

Update statement - syntax, UPDATE Statement   The UPDATE statement tra...

UPDATE Statement   The UPDATE statement transforms the values of the specified columns in one or more rows in the table or view. Syntax:

Tables within a table - sql, Tables within a Table - SQL Figure here ...

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

Entering and exiting - autonomous transaction, Entering and Exiting If...

Entering and Exiting If you enter the executable part of an autonomous routine, the major transaction suspends. When you exit the routine, the major transaction resumes. To ex

Triggers, At times, customers make mistakes in submitting their orders and ...

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

Best practices/Data Warhousing, What are 3 good practices of modeling and/o...

What are 3 good practices of modeling and/or implementing data warehouses?

Semijoin and composition - sql, Semijoin and Composition - SQL For sem...

Semijoin and Composition - SQL For semijoin, the dyadic relational operator MATCHING, defined thus: r1 MATCHING r2, where r1 and r2 are relations such that r1 JOIN r2 is de

Parameter and keyword description - insert statement, Parameter and Keyword...

Parameter and Keyword Description:   table_reference: This identifies a table or view which should be available when you execute the INSERT statement, and for that you sho

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd