December 2010
Intermediate to advanced
451 pages
11h 16m
English
Your code contains a nested loop, and you want the inner loop to have the ability to exit from both loops and stop iteration completely.
Use loop labels for both loops and then reference either loop within an EXIT statement by following the EXIT keyword with a loop label. The following example prints out a series of numbers. During each iteration, the inner loop will increment until it reaches an odd number. At that point, it will pass control to the outer loop again. The outer loop will be exited when the index for the inner loop is greater than or equal to the number ten.
BEGIN
<<outer>> for idx1 in 1 .. 10 loop
<<inner>> for idx2 in 1 .. 10 loop
dbms_output.put(idx2); exit ...Read now
Unlock full access