SlideShare a Scribd company logo
PACKAGES
Introduction
• A package is a collection of stored functions,
  procedures and exceptions.
• A package is compiled and stored in database as
  an object.
Advantages of Packages
• Modularity -All related functions and procedures can be
    grouped together into a single unit called “package”.
•   Easier application design – Packages ease the process
    of granting privileges. A privilege given on a package
    passes on to all the functions and procedures within it.
•   Overloading: Packages enable to perform “overloading”
    of functions and procedures.
•   Improves Performance: Packages improve performance
    by loading the multiple objects into memory at once,
    therefore calls to related programs do not require physical
    I/O.
•   Sharing of variables: All the functions and procedures
    within a package can share variables among them
COMPONENTS OF PACKAGES
• A package comprises 2 parts:
• A specification : It contains the list of various
  functions/procedure names which will be a part of the
  package.
• A body : This contains the actual PL/SQL code
  implementing the logics of functions and procedures
  declared in “specification”.
Creating a Package-SYNTAX
CREATE [OR REPLACE] PACKAGE package_name {IS|
AS}
Procedure_or_function_specification_1;
Procedure_or_function_specification_2;
End [package_name];
/
CREATE [OR REPLACE] PACKAGE body package_name
{IS|AS}
Procedure_or_function_body_1;
Procedure_or_function_body_2;
End [package_name];
/
Calling Package functions and
procedures
• A procedure/function within a package can be called by using
 the foll. syntax:
CALL package_name.{procedure_name}


Within a calling program, invoking can be done as follows:
begin
package_name.procedure_name
End;

begin
Variable:=package_name.function_name
End;
DROPPING PACKAGE

To drop a package, the foll. syntax is used:
Drop package package_name;
Eg:
Drop package pack1;

More Related Content

Viewers also liked

[Contoh] ramalan topikal bab 1 maths tahun 5 2012
[Contoh] ramalan topikal bab 1  maths tahun 5 2012[Contoh] ramalan topikal bab 1  maths tahun 5 2012
[Contoh] ramalan topikal bab 1 maths tahun 5 2012shahafiy
 
Bolsa de valores presentacion
Bolsa de valores presentacionBolsa de valores presentacion
Bolsa de valores presentacion
July Posada Duque
 
La salute nell'era di internet
La salute nell'era di internetLa salute nell'era di internet
La salute nell'era di internet
Cristina Da Rold
 
Macroalgas
MacroalgasMacroalgas
Macroalgas
sheenberry
 
Food retail-management1 (3)
Food retail-management1 (3)Food retail-management1 (3)
Food retail-management1 (3)Bhupendra Sonkar
 

Viewers also liked (7)

Chapter 4 rafael
Chapter 4 rafaelChapter 4 rafael
Chapter 4 rafael
 
[Contoh] ramalan topikal bab 1 maths tahun 5 2012
[Contoh] ramalan topikal bab 1  maths tahun 5 2012[Contoh] ramalan topikal bab 1  maths tahun 5 2012
[Contoh] ramalan topikal bab 1 maths tahun 5 2012
 
How to reset canon mp145
How to reset canon mp145How to reset canon mp145
How to reset canon mp145
 
Bolsa de valores presentacion
Bolsa de valores presentacionBolsa de valores presentacion
Bolsa de valores presentacion
 
La salute nell'era di internet
La salute nell'era di internetLa salute nell'era di internet
La salute nell'era di internet
 
Macroalgas
MacroalgasMacroalgas
Macroalgas
 
Food retail-management1 (3)
Food retail-management1 (3)Food retail-management1 (3)
Food retail-management1 (3)
 

Similar to Packages

Oracle - Program with PL/SQL - Lession 12
Oracle - Program with PL/SQL - Lession 12Oracle - Program with PL/SQL - Lession 12
Oracle - Program with PL/SQL - Lession 12
Thuan Nguyen
 
(ATS6-DEV06) Using Packages for Protocol, Component, and Application Delivery
(ATS6-DEV06) Using Packages for Protocol, Component, and Application Delivery(ATS6-DEV06) Using Packages for Protocol, Component, and Application Delivery
(ATS6-DEV06) Using Packages for Protocol, Component, and Application Delivery
BIOVIA
 
plsql les03
 plsql les03 plsql les03
plsql les03
sasa_eldoby
 
Oracle db subprograms
Oracle db subprogramsOracle db subprograms
Oracle db subprogramsSimon Huang
 
Packages in java
Packages in javaPackages in java
Packages in java
SahithiReddyEtikala
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functions
Amrit Kaur
 
]project-open[ Package Manager
]project-open[ Package Manager]project-open[ Package Manager
]project-open[ Package Manager
Klaus Hofeditz
 
06 Using More Package Concepts
06 Using More Package Concepts06 Using More Package Concepts
06 Using More Package Concepts
rehaniltifat
 
Mac Application Packaging
Mac Application PackagingMac Application Packaging
Mac Application Packaging
Dell World
 
Packages in java
Packages in javaPackages in java
Packages in java
jamunaashok
 
Packages in java
Packages in javaPackages in java
Packages in java
Jancypriya M
 
packages unit 5 .ppt
packages  unit 5 .pptpackages  unit 5 .ppt
packages unit 5 .ppt
thenmozhip8
 
David Weston SSIS Portfolio
David Weston SSIS PortfolioDavid Weston SSIS Portfolio
David Weston SSIS Portfolio
dlweston
 
Ssis 2008
Ssis 2008Ssis 2008
Ssis 2008
maha2886
 
Unlocked package
Unlocked packageUnlocked package
Puppet | Custom Modules & Using the Forge
Puppet | Custom Modules & Using the ForgePuppet | Custom Modules & Using the Forge
Puppet | Custom Modules & Using the Forge
Aaron Bernstein
 
uml reference package_diagram
uml reference package_diagramuml reference package_diagram
uml reference package_diagram
Mohamed Zakarya Abdelgawad
 
Presentation: eSubmissions in Australia - Part 2
Presentation: eSubmissions in Australia - Part 2Presentation: eSubmissions in Australia - Part 2
Presentation: eSubmissions in Australia - Part 2
TGA Australia
 

Similar to Packages (20)

Oracle - Program with PL/SQL - Lession 12
Oracle - Program with PL/SQL - Lession 12Oracle - Program with PL/SQL - Lession 12
Oracle - Program with PL/SQL - Lession 12
 
(ATS6-DEV06) Using Packages for Protocol, Component, and Application Delivery
(ATS6-DEV06) Using Packages for Protocol, Component, and Application Delivery(ATS6-DEV06) Using Packages for Protocol, Component, and Application Delivery
(ATS6-DEV06) Using Packages for Protocol, Component, and Application Delivery
 
plsql les03
 plsql les03 plsql les03
plsql les03
 
Oracle db subprograms
Oracle db subprogramsOracle db subprograms
Oracle db subprograms
 
Store programs
Store programsStore programs
Store programs
 
Packages in java
Packages in javaPackages in java
Packages in java
 
5. stored procedure and functions
5. stored procedure and functions5. stored procedure and functions
5. stored procedure and functions
 
]project-open[ Package Manager
]project-open[ Package Manager]project-open[ Package Manager
]project-open[ Package Manager
 
06 Using More Package Concepts
06 Using More Package Concepts06 Using More Package Concepts
06 Using More Package Concepts
 
Mac Application Packaging
Mac Application PackagingMac Application Packaging
Mac Application Packaging
 
Uml2
Uml2Uml2
Uml2
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Packages in java
Packages in javaPackages in java
Packages in java
 
packages unit 5 .ppt
packages  unit 5 .pptpackages  unit 5 .ppt
packages unit 5 .ppt
 
David Weston SSIS Portfolio
David Weston SSIS PortfolioDavid Weston SSIS Portfolio
David Weston SSIS Portfolio
 
Ssis 2008
Ssis 2008Ssis 2008
Ssis 2008
 
Unlocked package
Unlocked packageUnlocked package
Unlocked package
 
Puppet | Custom Modules & Using the Forge
Puppet | Custom Modules & Using the ForgePuppet | Custom Modules & Using the Forge
Puppet | Custom Modules & Using the Forge
 
uml reference package_diagram
uml reference package_diagramuml reference package_diagram
uml reference package_diagram
 
Presentation: eSubmissions in Australia - Part 2
Presentation: eSubmissions in Australia - Part 2Presentation: eSubmissions in Australia - Part 2
Presentation: eSubmissions in Australia - Part 2
 

Packages

  • 2. Introduction • A package is a collection of stored functions, procedures and exceptions. • A package is compiled and stored in database as an object.
  • 3. Advantages of Packages • Modularity -All related functions and procedures can be grouped together into a single unit called “package”. • Easier application design – Packages ease the process of granting privileges. A privilege given on a package passes on to all the functions and procedures within it. • Overloading: Packages enable to perform “overloading” of functions and procedures. • Improves Performance: Packages improve performance by loading the multiple objects into memory at once, therefore calls to related programs do not require physical I/O. • Sharing of variables: All the functions and procedures within a package can share variables among them
  • 4. COMPONENTS OF PACKAGES • A package comprises 2 parts: • A specification : It contains the list of various functions/procedure names which will be a part of the package. • A body : This contains the actual PL/SQL code implementing the logics of functions and procedures declared in “specification”.
  • 5. Creating a Package-SYNTAX CREATE [OR REPLACE] PACKAGE package_name {IS| AS} Procedure_or_function_specification_1; Procedure_or_function_specification_2; End [package_name]; / CREATE [OR REPLACE] PACKAGE body package_name {IS|AS} Procedure_or_function_body_1; Procedure_or_function_body_2; End [package_name]; /
  • 6. Calling Package functions and procedures • A procedure/function within a package can be called by using the foll. syntax: CALL package_name.{procedure_name} Within a calling program, invoking can be done as follows: begin package_name.procedure_name End; begin Variable:=package_name.function_name End;
  • 7. DROPPING PACKAGE To drop a package, the foll. syntax is used: Drop package package_name; Eg: Drop package pack1;