Tell Me
 

Creating the Package Specification

Previous previous|next Next Page

To create packages, you declare all public constructs in the package specification.

  • Specify the OR REPLACE option, if overwriting an existing package specification.
  • Initialize a variable with a constant value or formula within the declaration, if required; otherwise, the variable is initialized implicitly to NULL.
  • The package specification should contain procedure and function headings terminated by a semicolon, without the IS (or AS) keyword and its PL/SQL block. The implementation of a procedure or function that is declared in a package specification is done in the package body.
CREATE [OR REPLACE] PACKAGE package_name 
IS|AS
public type and variable declarations
subprogram specifications
END [package_name]
CREATE OR REPLACE PACKAGE hr_pack 
IS
PROCEDURE raise_salary
(p_id IN employees.employee_id%TYPE,
p_percent IN NUMBER); FUNCTION get_sal (p_id IN employees.employee_id%TYPE) RETURN NUMBER;
END hr_pack;