G-4330: Always use a CURSOR FOR loop to process the complete cursor results unless you are using bulk operations.
Minor
Maintainability
Reason
It is easier for the reader to see, that the complete data set is processed. Using SQL to define the data to be processed is easier to maintain and typically faster than using conditional processing within the loop.
Since an exit
statement is similar to a goto
statement,
it should be avoided, whenever possible.
Example (bad)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
Example (good)
1 2 3 4 5 6 7 8 9 10 11 12 |
|