I have this block which gives me all the SUNDAYS between a given date range. This prints all the sundays, but there's a bug in this code.

sql Code:
  1. /*
  2.                   Anonymous block to get all sundays between a given date range
  3. */
  4. DECLARE
  5. FROM_DT DATE:= TO_DATE('01/01/2009','mm/dd/yyyy');
  6. TO_DT DATE:= TO_DATE('01/31/2009','mm/dd/yyyy');
  7. X VARCHAR2(30);
  8. BEGIN
  9.       WHILE NOT FROM_DT > TO_DT
  10.       LOOP
  11.         SELECT NEXT_DAY(FROM_DT,'SUN') INTO X from dual;
  12.          --I want to print X only if it is a SUNDAY and just once.
  13.                 DBMS_OUTPUT.PUT_LINE(X);
  14.         FROM_DT := FROM_DT + 1;
  15.       END LOOP;  
  16. END;

In the above code, I want to print each date, just once.

Any idea?