I was working on a project recently and I came across needing a need to distribute orders to zones until certain conditions were met. I found the EXIT statement came in handy for this PL/SQL Block.
Oracle/PLSQL: Exit Statement
The syntax for the EXIT statement is:
EXIT [WHEN boolean_condition];
The EXIT statement is most commonly used to terminate LOOP statements.
Let’s take a look at an example:
LOOP distribute_orders(); EXIT WHEN order_distribute_conditions_met(); END LOOP;
In this example, the LOOP would terminate when the conditions are met.