Creation of PL/SQL Packages
You create a package in two parts: the specification and the body. The package specification declares all public constructs of the package, whereas the package body defines all constructs (public and private) of the package.
lean six sigma certification training courses malaysia
The following example shows part of a statement that creates the package specification for employees_management, which encapsulates several subprograms used to manage an employee database. Each part of the package is created with a different statement.
CREATE PACKAGE employees_management AS FUNCTION hire_employees (last_name VARCHAR2, job_id VARCHAR2, manager_id NUMBER, salary NUMBER, commission_pct NUMBER, department_id NUMBER) RETURN NUMBER; PROCEDURE fire_employees(employee_id NUMBER); PROCEDURE salary_raise(employee_id NUMBER, salary_incr NUMBER); . . . no_sal EXCEPTION; END employees_management;
The specification declares the function hire_employees, the procedures fire_employees and salary_raise, and the exception no_sal. All of these public program objects are available to users who have access to the package.
The CREATE PACKAGE BODY statement defines objects declared in the specification. The package body must be created in the same schema as the package. After creating the package, you can develop applications that call any of these public procedures or functions or raise any of the public exceptions of the package.
Comments
Post a Comment