create table to hold all weekday for further computation
--create table weekday (valuation_date date)
--alter table weekday add primary key (valuation_date);
set serveroutput on
declare
lv_start_date date := trim(to_date('20080201','yyyymmdd'));
lv_date date;
lv_week pls_integer;
begin
select trim(current_date) into lv_date from dual;
while lv_start_date <= lv_date loop
lv_week := to_number(to_char (lv_start_date, 'D')) - 1;
if lv_week>=1 and lv_week<=5 then
dbms_output.put_line(lv_start_date);
insert into weekday values(lv_start_date);
end if;
select trim(lv_start_date+1) into lv_start_date from dual;
end loop;
commit;
end;
/
No comments:
Post a Comment