Skip to main content
← PL/SQL Topics

Exception Handling

Explain how exceptions propagate through nested PL/SQL blocks

Exception Propagation

ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated

An unhandled exception propagates outward block by block until a handler matches or it reaches the client.

How it works

When an exception is raised, PL/SQL looks for a matching WHEN in the current block's EXCEPTION section. If none matches (or there is no section), the block terminates and the exception re-raises in the enclosing block, repeating outward. Statements after the failed block do not run unless that block was itself wrapped in a BEGIN/EXCEPTION/END. An exception raised inside a handler propagates to the enclosing block, not to another WHEN in the same section. Reaching the top unhandled returns the error to the caller and rolls back only the current statement.

How it works
BEGIN
  BEGIN
    RAISE NO_DATA_FOUND;
  EXCEPTION
    WHEN VALUE_ERROR THEN                 -- does not match
      DBMS_OUTPUT.PUT_LINE('inner value_error');
  END;
  DBMS_OUTPUT.PUT_LINE('never reached');
EXCEPTION
  WHEN NO_DATA_FOUND THEN                 -- caught here, one level out
    DBMS_OUTPUT.PUT_LINE('handled in outer block');
END;
/

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