不需要使用PL/SQL。
节假日使用以下内容:
select '01.01' hd from dual union all
select '15.01' from dual union all
select '19.01' from dual union all
select '28.05' from dual union all
select '04.07' from dual union all
select '08.10' from dual union all
select '11.11' from dual union all
select '22.11' from dual union all
select '25.12' from dual
要计算周末:
to_char(saleDate, 'd')
. 它返回一周中的若干天。但请注意,这取决于NLS设置。如果
NLS_TERRITORY
在设置中为
AMERICAN
,星期天是一周的第一天,在其他一些地区(例如欧洲国家)是第七天。
因此,查询是:
insert into times (saleDay, dayType)
select saleDate, case when h.hd is not null then 'Holiday'
when to_char(saleDate, 'd') in (1,7) then 'Weekend' -- I suppose you are American
else 'Weekday' end dayType
from sales s left join
(<holiday query above>) h
on h.hd = to_char(s.saleDate, 'dd.mm')
如果需要在PL/SQL中使用它,可以在过程中执行查询。