Packages

Domain Hosting image
Web Hosting
Dedicated server
ssl certificate
Web Design image
Email

A packages is a collection of related program objects stored together in the database. They are

Procedures
function
variables
constants
cursors
exceptions

Packages consists of two parts

PACKAGE SPECIFICATION and
PACKAGE BODY.
The specification declares the types, variables, constants, exceptions, cursors and subprograms. The book fully defines cursors and subprograms and implements the specification. The packages can't be called like subprograms.

PACKAGE name IS_SPECIFICATION
PUBLIC TYPE AND OBJECT DECLARATION
SUBPROGRAM SPECIFICATION
END [name];

Package body

The package body implements the package specification. That is, the package body contains the definition of every cursor and subprogram declared in the package specification. Subprograms defined in a package body are accessible outside the package only if their specifications also appear in the package specification.

PACKAGE BODY name IS-HIDDEN PART
PRIVATE TYPE AND OBJECT DECLARATION
SUBPROGRAM BODIES
BEGIN
.....
END [name);
PACKAGE TEST_PACK IS
PROCEDURE TEST_EMP (EMP ID NUMBER)
END TEST_PACK;
PACKAGE BODY TEST_PACK IS
PROCEDURE TEST_EMP (EMP ID NUMBER) IS
BEGIN
DELETE FROM EMP WHERE EMPNO = EMP_ID;
END TEST_EMP;
END TEST PACK;

To reference the objects declared with in a package you use this format
package_name.type_name
package_name.object name
package_name.subprogram name
The procedure declared with in the package test_pack is called as TEST PACK. TEST EMP (EMP_ID)

Calling packaged subprograms

Packaged subprograms must be referred using dot notation, as shown
emp_action.hir e employee(name,title,...);
This tells PL/SQL compiler that hire employee is found in the package emp_actions.

Advantages of package

• MODULARITY
• EASIER APPLICATION DESIGN
• INFORMATION HIDING
• ADDED FUNCTIONALITY
• BETTER PERFORMANCE



Domain Name Search

www.


Copyright (C) 2007. Web Domain design hosting. All rights reserved.