Oracle plsql 月历
生活随笔
收集整理的這篇文章主要介紹了
Oracle plsql 月历
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
declarev_year number := 2013;v_month number := &input_month;v_day number;v_lastday number;begindbms_output.put_line(v_year || '年' || v_month || '月的月歷');--轉(zhuǎn)換星期為數(shù)字,方便計(jì)算case substr(to_char(to_date(v_year || v_month,'yyyymm'),'day'),3,1)when '日' then v_day := 1;when '一' then v_day := 2;when '二' then v_day := 3;when '三' then v_day := 4;when '四' then v_day := 5;when '五' then v_day := 6;when '六' then v_day := 7;else null;end case;v_lastday := to_char(last_day(to_date(v_year || v_month,'yyyymm')),'dd');dbms_output.put_line('第一天為本周第' || v_day || '天');dbms_output.put_line('本月共' || v_lastday || '天');dbms_output.put_line(' 日 ?一 ?二 ?三 ?四 ?五 ?六');--PS:以上所有要用到的數(shù)據(jù)都已經(jīng)得到了,下面是展示--縮進(jìn)月的第一天for j in 1 .. v_day - 1 loopdbms_output.put(' ? ?');end loop;--順序打印每天for i in 1 .. v_lastday loopdbms_output.put(to_char(i,'99') || ' ');--如果遇到星期六,則換行(保證星期的標(biāo)識從1-7循環(huán))if v_day = 7 thendbms_output.put_line('');v_day := 1;elsev_day := v_day + 1;end if;end loop;--PS:空格在打印的時候,可能被省略,可以換成其他字符嘗試--輸出最后一行未能輸出的字符dbms_output.put_line('');end;
效果如下:
效果如下:
2013年2月的月歷
第一天為本周第6天
本月共28天
日 一 二 三 四 五 六
1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28
總結(jié)
以上是生活随笔為你收集整理的Oracle plsql 月历的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: IEPNGFix:Unclickable
- 下一篇: Oracle笔记:备份还原