However, exceptions cannot propagate across remote procedure calls (RPCs). Therefore, a PL/SQL block cannot catch an exception raised by a remote subprogram. For a workaround, see "Using raise_application_ error"
.
Figure 6 - 1, Figure 6 - 2, and Figure 6 - 3 illustrate the basic propagation rules.
Figure 6 - 1. Propagation Rules: Example 1
Figure 6 - 2. Propagation Rules: Example 2
Figure 6 - 3. Propagation Rules: Example 3
An exception can propagate beyond its scope, that is, beyond the block in which it was declared. Consider the following example:
BEGIN
...
DECLARE ---------- sub-block begins
past_due EXCEPTION;
BEGIN
...
IF ... THEN
RAISE past_due;
END IF;
END; ------------- sub-block ends
EXCEPTION
...
WHEN OTHERS THEN
ROLLBACK;
END;Because the block in which it was declared has no handler for the exception named past_due, it propagates to the enclosing block. But, according to the scope rules, enclosing blocks cannot reference exceptions declared in a sub-block. So, only an OTHERS handler can catch the exception.