FORMAT_ERROR_BACKTRACE and the Error Stack
ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated
FORMAT_ERROR_BACKTRACE reports the line where the error was actually raised, even after it has propagated.
How it works
In a handler, SQLERRM (or DBMS_UTILITY.FORMAT_ERROR_STACK) gives the error message, but not where it came from. DBMS_UTILITY.FORMAT_ERROR_BACKTRACE returns the call stack from the raise point to the current handler, including line numbers — essential when WHEN OTHERS is several calls away. Since 12c, UTL_CALL_STACK offers the same information in a structured, per-frame API. Log the backtrace before re-raising; do not let it be lost.
How it works
CREATE OR REPLACE PROCEDURE run_job AS
BEGIN
-- ... deep call chain ...
RAISE_APPLICATION_ERROR(-20500, 'step failed');
EXCEPTION
WHEN OTHERS THEN
INSERT INTO job_errors(err_msg, err_stack, logged_at)
VALUES (SQLERRM,
DBMS_UTILITY.FORMAT_ERROR_BACKTRACE,
SYSTIMESTAMP);
RAISE; -- keep propagating after logging
END;
/Related questions
GroundingGenerated
Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.