SQL>
SQL>
SQL>
SQL> -The IN operator used to test for long weekends.
SP2-0734: unknown command beginning "-The IN op..." - rest of line ignored.
SQL> SET SERVEROUTPUT ON
SQL> DECLARE
2 test_date DATE;
3 day_of_week VARCHAR2(3);
4 years_ahead INTEGER;
5 BEGIN
6 --Assign a date value to test_date.
7
8 test_date := TO_DATE('4-Jul-1997','dd-mon-yyyy');
9
10 FOR years_ahead IN 1..10 LOOP
11 day_of_week := TO_CHAR(test_date,'Dy');
12
13 IF day_of_week IN ('Mon','Fri','Sat','Sun') THEN
14 DBMS_OUTPUT.PUT_LINE(TO_CHAR(test_date,'dd-Mon-yyyy')|| ' A long weekend!');
15 ELSE
16 DBMS_OUTPUT.PUT_LINE(TO_CHAR(test_date,'dd-Mon-yyyy')|| ' Not a long weekend.');
17 END IF;
18 --Advance one year (12 months)
19 test_date := ADD_MONTHS(test_date,12);
20 END LOOP;
21 END;
22 /
04-Jul-1997 A long weekend!
04-Jul-1998 A long weekend!
04-Jul-1999 A long weekend!
04-Jul-2000 Not a long weekend.
04-Jul-2001 Not a long weekend.
04-Jul-2002 Not a long weekend.
04-Jul-2003 A long weekend!
04-Jul-2004 A long weekend!
04-Jul-2005 A long weekend!
04-Jul-2006 Not a long weekend.
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL>
|