My Oracle Support Banner

How to Handle Exceptions And Still Continue to Process a PL/SQL Procedure (Doc ID 1297175.1)

Last updated on JUNE 21, 2022

Applies to:

PL/SQL - Version 10.1.0.3 and later
Information in this document applies to any platform.

Goal

When using nested Loops, how to process the exception of the inner loop so that it continues processing instead of stopping the entire process?

Here is an example of code that has an outer loops that iterates 20 times. During the iteration if an Exception is encountered at any time the entire process stops.  This example, encounters an Exception, the Exception is handled but the procedure exits. The goal is to allow the outer loop to complete all 20 iterations even if an Exception occurs.

The following sample is designed to LOOP 20 times.
Within the LOOP there is a MOD function so that every 5 iterations a NO_DATA_FOUND exception is raised.
In this sample, only 5 iterations are completed then the exception handler is encountered and the entire procedure is exited.
The DBMS_OUTPUT outside the loop is not encountered due to the exception.




The question is how to enable the procedure to finish all 20 iterations even if an Exception is encountered?

Solution

To view full details, sign in with your My Oracle Support account.

Don't have a My Oracle Support account? Click to get started!


In this Document
Goal
Solution


My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.