Loading

日期列转换成星期

SQL> set serveroutput on 
SQL> declare 
  2  	cursor c_date is
	  3  	select hire_date from employees;
  4  	v_date date;
  5  	v_day varchar2(20);
  6  begin
  7  	open c_date;
  8  	loop 
  9  		fetch c_date into v_date;
 10  		exit when c_date%notfound;
 11  			begin
 12  				v_day := to_char(v_date,'D');
 13  					case v_day
 14  						when '1' then
 15  							dbms_output.put_line(to_char(v_date,'yyyy-mm-dd') ||' is sunday');
 16  						when '2' then 
 17  							dbms_output.put_line(to_char(v_date,'yyyy-mm-dd') ||' is monday');
 18  						when '3' then 
 19  							dbms_output.put_line(to_char(v_date,'yyyy-mm-dd') ||' is Tuesday');
 20  						when '4' then 
 21  							dbms_output.put_line(to_char(v_date,'yyyy-mm-dd') ||' is Wednesday');
 22  						when '5' then 
 23  							dbms_output.put_line(to_char(v_date,'yyyy-mm-dd') ||' is Thursday');
 24  						when '6' then 
 25  							dbms_output.put_line(to_char(v_date,'yyyy-mm-dd') ||' is Friday');
 26  						when '7' then 
 27  							dbms_output.put_line(to_char(v_date,'yyyy-mm-dd') ||' is Saturday');
 28  					end case;
 29  			end;
 30  	end loop;
 31  	close c_date;
 32  end;
 33  / 
1999-06-21 is monday
2000-01-13 is Thursday
1987-09-17 is Thursday
1996-02-17 is Saturday
1997-08-17 is sunday
1994-06-07 is Tuesday
1994-06-07 is Tuesday
1994-06-07 is Tuesday
1994-06-07 is Tuesday
1987-06-17 is Wednesday
1989-09-21 is Thursday
1993-01-13 is Wednesday
1990-01-03 is Wednesday
1991-05-21 is Tuesday
1997-06-25 is Wednesday
1998-02-05 is Thursday
1999-02-07 is sunday
1994-08-17 is Wednesday
1994-08-16 is Tuesday
1997-09-28 is sunday
1997-09-30 is Tuesday
1998-03-07 is Saturday
1999-12-07 is Tuesday
1994-12-07 is Wednesday
1995-05-18 is Thursday
1997-12-24 is Wednesday
1997-07-24 is Thursday
1998-11-15 is sunday
1999-08-10 is Tuesday
1996-07-18 is Thursday
1997-04-10 is Thursday
1995-05-01 is monday
1997-10-10 is Friday
1999-11-16 is Tuesday
1997-07-16 is Wednesday
1998-09-28 is monday
1999-01-14 is Thursday
2000-03-08 is Wednesday
1997-08-20 is Wednesday
1997-10-30 is Thursday
1997-02-16 is sunday
1999-04-10 is Saturday
1996-06-14 is Friday
1998-08-26 is Wednesday
1999-12-12 is sunday
2000-02-06 is sunday
1995-07-14 is Friday
1997-10-26 is sunday
1998-02-12 is Thursday
1998-04-06 is monday
1995-10-17 is Tuesday
1997-01-29 is Wednesday
1998-03-15 is sunday
1998-07-09 is Thursday
1996-10-01 is Tuesday
1997-01-05 is sunday
1997-03-10 is monday
1999-10-15 is Friday
2000-01-29 is Saturday
1997-01-30 is Thursday
1997-03-24 is monday
1997-08-20 is Wednesday
1998-03-30 is monday
1998-12-09 is Wednesday
1999-11-23 is Tuesday
1996-01-30 is Tuesday
1996-03-04 is monday
1996-08-01 is Thursday
1997-03-10 is monday
1997-12-15 is monday
1998-11-03 is Tuesday
1997-11-11 is Tuesday
1999-03-19 is Friday
2000-01-24 is monday
2000-02-23 is Wednesday
2000-03-24 is Friday
2000-04-21 is Friday
1997-03-11 is Tuesday
1998-03-23 is monday
1998-01-24 is Saturday
1999-02-23 is Tuesday
1999-03-24 is Wednesday
2000-04-21 is Friday
1996-05-11 is Saturday
1997-03-19 is Wednesday
1998-03-24 is Tuesday
1998-04-23 is Thursday
1999-05-24 is monday
2000-01-04 is Tuesday
1998-01-24 is Saturday
1998-02-23 is monday
1999-06-21 is monday
2000-02-03 is Thursday
1996-01-27 is Saturday
1997-02-20 is Thursday
1998-06-24 is Wednesday
1999-02-07 is sunday
1997-06-14 is Saturday
1997-08-13 is Wednesday
1998-07-11 is Saturday
1999-12-19 is sunday
1996-02-04 is sunday
1997-03-03 is monday
1998-07-01 is Wednesday
1999-03-17 is Wednesday
1998-04-24 is Friday
1998-05-23 is Saturday

PL/SQL procedure successfully completed.

  

posted @ 2021-01-22 16:27  李行行  阅读(91)  评论(0编辑  收藏  举报