Code Listing 5: Switching to a simple loop and avoiding redundant code

 1  DECLARE
 2     l_fine PLS_INTEGER := 0;
 3     l_date DATE := SYSDATE;
 4     l_overdue_count NUMBER := 1;
 5  BEGIN
 6     l_overdue_count :=
 7        overdue_pkg.countem (
 8           borrower_id => borrower_in,
 9           l_date);
10
11     WHILE (l_overdue_count > 0 AND l_fine < 10)
12     LOOP
13        update_fine_info (l_date, l_one_day_fine);
14
15        l_fine := l_fine + l_one_day_fine;
16        l_date := l_date + 1;
17        l_overdue_count :=
18           overdue_pkg.countem (
19              borrower_id => borrower_in,
20              l_date);
21*    END LOOP;