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:
/* Anonymous block to get all sundays between a given date range */ DECLARE FROM_DT DATE:= TO_DATE('01/01/2009','mm/dd/yyyy'); TO_DT DATE:= TO_DATE('01/31/2009','mm/dd/yyyy'); X VARCHAR2(30); BEGIN WHILE NOT FROM_DT > TO_DT LOOP SELECT NEXT_DAY(FROM_DT,'SUN') INTO X from dual; --I want to print X only if it is a SUNDAY and just once. DBMS_OUTPUT.PUT_LINE(X); FROM_DT := FROM_DT + 1; END LOOP; END;
In the above code, I want to print each date, just once.
Any idea?




Reply With Quote
