Wednesday, October 3, 2012

Exception Handling

How do you throw the exception after logging in the error?

Do a raise after logging the exception

CREATE OR REPLACE PROCEDURE sp_test IS
  ln NUMBER;
BEGIN
  ln := 5 / 0;
EXCEPTION
  WHEN OTHERS THEN
    dbms_output.put_line('Error');
    RAISE;
END;

Output would be
Error

And “ORA-01476: divisor is equal to zero” Will be raised

No comments:

Post a Comment