Forward Declarations
ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated
A forward declaration is a subprogram's header with no body, letting two private routines call each other.
How it works
The compiler resolves names top to bottom in a package body, so a private procedure cannot call another private one declared later — unless you first put a forward declaration (just the signature, ending in a semicolon) near the top, then the full body anywhere below. This is what makes mutual recursion between two private routines possible. Public subprograms do not need it because their spec already declares them.
How it works
CREATE OR REPLACE PACKAGE BODY parser_pkg AS
PROCEDURE parse_expr(p IN OUT VARCHAR2); -- forward declaration
PROCEDURE parse_term(p IN OUT VARCHAR2) IS
BEGIN
IF SUBSTR(p, 1, 1) = '(' THEN
p := SUBSTR(p, 2);
parse_expr(p); -- calls a routine defined later
END IF;
END;
PROCEDURE parse_expr(p IN OUT VARCHAR2) IS
BEGIN
parse_term(p);
END;
END parser_pkg;
/Related questions
GroundingGenerated
Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.