• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

使用PLSQL 打印日历

mysql 搞代码 4年前 (2022-01-09) 24次浏览 已收录 0个评论

最近有些闲,看完了concept突然有种空虚的感觉。闲话不多说。 用PLSQL写了一个打印日历的功能。 create or replace package disp

最近有些闲,,看完了concept突然有种空虚的感觉。闲话不多说。

用PLSQL写了一个打印日历的功能。

create or replace package display_date is
procedure display_spec_mon (year number , month number) ;
end ;

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) 本文来源gaodai#ma#com搞*!代#%^码$网*:= ‘February’ ;

conv_mon(3) := ‘Marcy’ ;
conv_mon(4) := ‘April’ ;

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 ;

执行结果:

_sys@DAVID> exec display_date.display_spec_mon(2013,10) ;
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 18 19
20 21 22 23 24 25 26
27 28 29 30 31

PL/SQL procedure successfully completed.

_sys@DAVID> exec display_date.display_spec_mon(2012,12) ;
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 18 19 20 21 22
23 24 25 26 27 28 29
30 31

PL/SQL procedure successfully completed.


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:使用PLSQL 打印日历

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址