user2783755
user2783755

Reputation: 588

PL/SQL raise handled exception

How can I throw cached exception in PL/SQL?

For example I have procedure, where I catch all exceptions:

  EXCEPTION
   WHEN OTHERS THEN
      rollback;

and then I want to throw catched exception to procedure caller.

Thanks in advance!

Upvotes: 1

Views: 541

Answers (2)

William Robertson
William Robertson

Reputation: 15991

To re-raise the exception, just use

raise;

To define a custom application error, look at raise_application_error, e.g.

raise_application_error(-20001, 'Warp core implosion imminent', true);

It's worth bearing in mind that due to what I've just decided to call the Exception Handling Uncertainty Principle, there is always a trade-off between reporting the full exception details and doing something about the exception.

Upvotes: 2

Tony Andrews
Tony Andrews

Reputation: 132570

Just add raise;:

EXCEPTION
  WHEN OTHERS THEN
    rollback;
    raise;

Upvotes: 3

Related Questions