WHEN OTHERS and Re-Raising
ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated
WHEN OTHERS catches every exception; swallowing it silently hides bugs, so log and RAISE.
How it works
WHEN OTHERS THEN matches any exception not caught earlier. A handler that only logs and then falls through (no RAISE) tells the caller the block succeeded when it did not — one of the most common sources of silent data corruption. The safe pattern is: capture SQLERRM and FORMAT_ERROR_BACKTRACE, write them somewhere durable (ideally via an autonomous-transaction logger so the log survives the rollback), then RAISE (or RAISE_APPLICATION_ERROR) so the failure still surfaces.
How it works
BEGIN
-- risky work
UPDATE accounts SET balance = balance - 100 WHERE account_id = -1;
IF SQL%ROWCOUNT = 0 THEN RAISE NO_DATA_FOUND; END IF;
EXCEPTION
WHEN OTHERS THEN
err_log_pkg.record(SQLCODE, SQLERRM, DBMS_UTILITY.FORMAT_ERROR_BACKTRACE);
RAISE; -- do NOT stop here
END;
/Related questions
GroundingGenerated
Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.