Coba ini, buat nampilin per tahun:
create or replace
procedure calendar (year in number)
is
h_year number;
ldom number (2);
sgmnt varchar2(5);
mname varchar (9);
wday number (1);
sgmnt_cnt number := 0;
begin
h_year := nvl (year, to_number (to_char (sysdate, 'YYYY')));
if h_year between 1583 and 9999 then
for month in 1 .. 12 loop
select substr (last_day (to_date (h_year ||
month, 'YYYYMM')), 1, 2)
into ldom
from dual;
select to_char (to_date (month, 'MM'), 'Month')
into mname
from dual;
select to_number (to_char (to_date (h_year ||
month, 'YYYYMM'), 'D'))
into wday
from dual;
--
dbms_output.put_line ('.');
dbms_output.put_line ('.');
dbms_output.put_line ('. ' || rtrim (mname) || ' - ' ||
h_year);
dbms_output.put_line ('.');
dbms_output.put_line ('.SUN MON TUE WED THU FRI
SAT');
dbms_output.put_line ('+----+----+----+----+----+----+---
-+');
--
for x in 1 .. wday - 1 loop
dbms_output.put ( '| ');
end loop;
--
for day in 1 .. ldom loop
if (day < 10) then
sgmnt := '| ' || day || ' ';
else
sgmnt := '| ' || day || ' ';
end if;
sgmnt_cnt := sgmnt_cnt + 1;
if mod (day + (wday - 1), 7) = 0 then
dbms_output.put (sgmnt || '|');
dbms_output.new_line;
dbms_output.put_line ('+----+----+----+----+----
+----+----+');
sgmnt_cnt := 0;
else
dbms_output.put (sgmnt);
end if;
end loop;
--
if sgmnt_cnt between 1 and 6 then
dbms_output.put ('|');
end if;
dbms_output.new_line;
if sgmnt_cnt = 1 then
dbms_output.put_line ('+----+');
elsif
sgmnt_cnt = 2 then
dbms_output.put_line ('+----+----+');
elsif
sgmnt_cnt = 3 then
dbms_output.put_line ('+----+----+----+');
elsif
sgmnt_cnt = 4 then
dbms_output.put_line ('+----+----+----+----+');
elsif
sgmnt_cnt = 5 then
dbms_output.put_line ('+----+----+----+----+----+');
elsif
sgmnt_cnt = 6 then
dbms_output.put_line ('+----+----+----+----+----+----
+');
end if;
end loop;
else
raise value_error;
end if;
exception
when others then
dbms_output.put_line ('* input year error *');
end calendar;
Untuk manggilnya : exec calendar(thn_brp?)
ex: exec calendar(2006)
Regards, Bagus Galih P.
--- In [email protected], fata hudaya <[EMAIL PROTECTED]>
wrote:
>
> Dear Master,
>
> Saya mo tanya, gimana ya cara meng-query Kalender di SQL*Plus ?
Dengan menggunakan parameter bulan apa yang akan kita tampilkan atau
semua bulan dalam 1 tahun.
> c/o :
>
> Agustus - 2006
> MIN SEN SEL RAB KAM JUM SAB
> 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
>
> Mohon pencerahannya...
>
> Many Thanks & Best Regard,
>
> Fata Hudaya,
> +628567143271
> [EMAIL PROTECTED]
>
>
>
> [Non-text portions of this message have been removed]
>
--
-----------I.N.D.O - O.R.A.C.L.E---------------
Keluar: [EMAIL PROTECTED]
Website: http://indo-oracle.blogspot.com
Mirror: http://indooracle.wordpress.com
-----------------------------------------------
Bergabung dengan Indonesia Thin Client User Groups,
Terminal Server, Citrix, New Moon Caneveral, di:
http://indo-thin.blogspot.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/indo-oracle/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/