Package Specification:
The package specification holds public declarations. The scope of these declarations is global to the package and local to the database schema. Then, the declared items are accessible from the application and from anywhere in the package.
The specification lists the package resources available to applications. All the information in which the application requires to use the resources is in the specification. For instance, the following declaration displays that the function named fac takes one argument of type INTEGER and returns a value of type INTEGER:
FUNCTION fac (n INTEGER) RETURN INTEGER; #returns n!#
That is the information which requires the user to call the function. The underlying implementation of fac (for example, whether it is recursive or iterative). Be required not considered
Only cursors and subprograms have an underlying implementation or definition. Then, if a specification declares only types, variables, constants and exceptions, the package body is unnecessary. Let consider the subsequent bodiless package:
-- a bodiless package
CREATE or replace PACKAGE trans_data AS # for create a package#
TYPE TimeRec IS RECORD (
minutes SMALLINT,
hours SMALLINT);
TYPE TransRec IS RECORD (category VARCHAR2 (1), account INTEGER, amount REAL, time TimeRec);
minimum_balance CONSTANT REAL := 10.00;
number_processed INTEGER;
insufficient_funds EXCEPTION;
END trans_data;
The package trans_data requires no body since types, constants, variables and exceptions do not have an underlying implementation. Like as packages global variables-usable through subprograms and database triggers-which persist by a session to be defined.