0
begin

  begin

     do something;

  exception

    when no_data_found then
      raise_application_error(-20000,"Message");

  end;

 exception

    when others then
        raise_application_error(-20000,"Other message");

 end;

My problem is when the compiler catches the "Message" error it alsos catches the "Other message" error. Why does it happen?

1 Answer 1

4

try to put them in the same exception block.

If you put when others in a separated block, it will alwasy be raised, as... there's no already catched exception to exclude from others in that block.

From doc

The WHEN OTHERS clause is used to trap all remaining exceptions that have not been handled by your Named System Exceptions and Named Programmer-Defined Exceptions.

So

exception

    when no_data_found then
      raise_application_error(-20000,"Message");

    when others then
      raise_application_error(-20000,"Other message");

end;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.