Package Spec vs. Body
ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated
The spec declares the public interface; the body supplies the implementation and private helpers.
How it works
The package specification (CREATE PACKAGE) declares the public interface — the procedures, functions, types, and variables/constants a caller can see. The package body (CREATE PACKAGE BODY) supplies the actual implementation, plus any private helper subprograms and variables not declared in the spec at all. Callers only ever depend on the spec, so the body can be recompiled independently without invalidating dependent objects, as long as the spec's signatures don't change.
How it works
CREATE OR REPLACE PACKAGE emp_pkg AS
FUNCTION get_annual_salary(p_employee_id NUMBER) RETURN NUMBER;
PROCEDURE give_raise(p_employee_id NUMBER, p_pct NUMBER);
END emp_pkg;
/
CREATE OR REPLACE PACKAGE BODY emp_pkg AS
FUNCTION get_annual_salary(p_employee_id NUMBER) RETURN NUMBER IS
v_salary employees.salary%TYPE;
BEGIN
SELECT salary * 12 INTO v_salary FROM employees WHERE employee_id = p_employee_id;
RETURN v_salary;
END get_annual_salary;
PROCEDURE give_raise(p_employee_id NUMBER, p_pct NUMBER) IS
BEGIN
UPDATE employees SET salary = salary * (1 + p_pct/100) WHERE employee_id = p_employee_id;
END give_raise;
END emp_pkg;
/Related questions
GroundingGenerated
Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.