Print calendar with PLSQL

Source: Internet
Author: User


I recently used PLSQL to print the calendar. After reading it, the concept suddenly feels empty. Not much gossip. I used PLSQL to write a calendar printing function. Www.2cto.com [SQL] create or replace package display_date is procedure display_spec_mon (year number, month number); end; [SQL] create or replace package body display_date is type t_conv_mon is table of varchar2 (10); conv_mon t_conv_mon: = t_conv_mon (); procedure display_title (year number, month number) is begin dbms_output.put_line (year | '. '| conv_mon (month); dbms_output.put_line (lpad ('', 21,'-'); dbms_output.put_line ('su Mo Tu We Th Fr Sa'); end; procedure display_spec_mon (year number, month number) is current_mon date; current_line varchar2 (21); begin -- dbms_output.put_line (year | lpad (month | '', 2, '0 ') | '01'); display_title (year, month); current_mon: = to_date (year | lpad (month | '', 2, '0 ') | '01', 'yyyymmdd'); for I in 1 .. (add_months (current_mon, 1)-current_mon) loop if I = 1 then current_line: = current_line | (lpad ('', (to_char (current_mon + I-1, 'd ') -1) * 3, '--'); end if; current_line: = current_line | rpad (I | '', 3 ,''); if length (current_line)> = 21 then dbms_output.put_line (current_line); current_line: = ''; end if; end loop; dbms_output.put_line (current_line); end; begin conv_mon.extend (12 ); conv_mon (1): = 'january '; conv_mon (2): = 'february'; conv_mon (3): = 'marcy '; conv_mon (4): = 'cmdl '; conv_mon (5): = 'may'; conv_mon (6): = 'june'; conv_mon (7): = 'july'; conv_mon (8): = 'August '; conv_mon (9): = 'September '; conv_mon (10): = 'October'; conv_mon (11): = 'november'; conv_mon (12): = 'december '; end; execution result: [SQL] _ sys @ DAVID> exec display_date.display_spec_mon (2013. october -------------------- Su Mo Tu We Th Fr Sa -- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 19 20 21 22 24 25 26 27 28 29 30 31 PL/SQL procedure successfully completed. _ sys @ DAVID> exec display_date.display_spec_mon (hz12); 2012. december -------------------- Su Mo Tu We Th Fr Sa -- 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 19 20 21 22 23 24 25 26 27 28 29 30 31 PL/SQL procedure successfully completed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.