create or replace procedure QD_xxx (p_date date)is
begin
--删除
delete from xxx where tjsj=to_char(p_date,'yyyyMM');
commit ;
----插入
insert into xxx (SJDM,Sjmc,Fjdm,fjmc,Pcsdm,Pcsmc,tjsj, CJPJZL)
select t.sss,t.sssc,t.nn', t.ssfxjdwmc,t.CJDW,t.CJDW,t.tjy tjsj, avg(t.ZWY+t.ZWE)/2 cjzlavg
from
(select sssjm,
sssjmc,
ssfxwdm,
ssfxwmc,
CJDW,
CJDW_GAJGMC,
-- to_date(to_char(cjsj,'yyyy-MM-dd'),'yyyy-MM-dd') tjy,
to_char(cjsj,'yyyyMM') tjy,
ZWY,
ZWE_
from 表名)t
where t.tjy=to_char(p_date,'yyyyMM')
group by t.sss,t.sssjc,t.ssfxjdm, t.ssfxj,t.CJD,t.CJD,t.tjy ;
commit ;
exception when others then
rollback ;
end QD_xxx;