Skip to main content
← PL/SQL Topics

Packages & Modularity

Explain declaring shared constants, types and cursors in a package specification

Shared Constants, Types and Cursors in a Package Spec

ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated

A package spec is the natural home for definitions many programs must agree on — public constants, types and cursor declarations.

How it works

Anything declared in the spec is public: reference it as pkg.name. Put status codes and magic numbers there as CONSTANT, shared collection/record TYPEs so callers can declare variables of pkg.type_name, and public cursor declarations (spec has the header, body has the SELECT). This gives one authoritative definition and lets client code compile against the contract without seeing the body.

How it works
CREATE OR REPLACE PACKAGE invoice_pkg IS
  c_status_draw   CONSTANT VARCHAR2(1) := 'D';
  c_status_posted CONSTANT VARCHAR2(1) := 'P';

  TYPE invoice_id_tab IS TABLE OF NUMBER INDEX BY PLS_INTEGER;

  CURSOR c_unposted RETURN ap_invoices_all%ROWTYPE;  -- header only

  PROCEDURE post(p_ids invoice_id_tab);
END invoice_pkg;
/

Related questions

GroundingGenerated

Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.

Have a follow-up, or a different question?

Continue in Ask Oracle AI