Local (Nested) Subprograms
ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated
You can define procedures and functions inside the DECLARE section of a block or another subprogram; they are private to it.
How it works
A subprogram declared in the declarative part of a block, procedure, function or trigger is local: only visible within that enclosing unit, and it can see the enclosing unit's variables. It is the right tool for factoring repeated logic that is meaningless outside this one routine, avoiding a schema-level object. Local subprograms must be declared after all other declarations in the section.
How it works
CREATE OR REPLACE PROCEDURE post_batch(p_batch_id NUMBER) AS
v_count PLS_INTEGER := 0;
FUNCTION is_balanced(p_id NUMBER) RETURN BOOLEAN IS -- local function
v_diff NUMBER;
BEGIN
SELECT SUM(entered_dr) - SUM(entered_cr) INTO v_diff
FROM gl_je_lines WHERE je_batch_id = p_id;
RETURN NVL(v_diff, 0) = 0;
END;
BEGIN
IF is_balanced(p_batch_id) THEN
v_count := v_count + 1;
END IF;
END;
/Related questions
GroundingGenerated
Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.