SQL>
SQL> DECLARE
2 curr_date DATE := SYSDATE;
3 last_date DATE;
4 step PLS_INTEGER := 1000;
5 BEGIN
6 LOOP
7 BEGIN
8 last_date := curr_date;
9 curr_date := curr_date + step;
10 EXCEPTION
11 WHEN OTHERS
12 THEN
13 IF step = 1
14 THEN
15 DBMS_OUTPUT.PUT_LINE ('Last date: ' || TO_CHAR (last_date, 'Month DD, YYYY'));
16 EXIT;
17 ELSE
18 step := step / 2;
19 curr_date := last_date;
20 END IF;
21 END;
22 END LOOP;
23 END;
24 /
Last date: December 31, 9999
PL/SQL procedure successfully completed.