Exception Handling

Published July 26, 2025 By Sai Sree Ram Gundepudi

Exception Handling in PL/SQL

Use EXCEPTION to catch and handle errors.

BEGIN
  SELECT salary INTO v_sal FROM employees WHERE employee_id = 999;
EXCEPTION
  WHEN NO_DATA_FOUND THEN
    DBMS_OUTPUT.PUT_LINE('Employee not found.');
  WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('Some error occurred.');
END;

Was this solution helpful?

Your feedback helps improve our technical knowledge repository.

Share this article