逻
逻辑鱼
Unregistered / Unconfirmed
GUEST, unregistred user!
CREATE OR REPLACE PROCEDURE gbgl_pro_hbgbtj AS
i number(9,0);
begin
delete from gbgl_qy_cjgbtjb;
declare
cursor plts_cursor1 is
SELECT swhere as sid from gbgl_temp_qycjhbgbtjb;
pltsrow plts_cursor1%ROWTYPE;
begin
open plts_cursor1;
loop
fetch plts_cursor1 into pltsrow;
exit when plts_cursor1%notfound;
select nvl(max(id),0) into i from gbgl_qy_cjgbtjb;
insert into gbgl_qy_cjgbtjb
(id,hj,dy,fn,dqgb,pjnl,nl35,nl40,nl45,nl50,nl55,nl56,yjs,dx,dz,zz,g
z,jsj,gj,zj,zlj,yj)
select i+1 id,count(distinct a.id) hj,
sum(case when d.zzmmid in (select id from ryxx_bm_zzmm where id=3)
then 1 else 0 end) dy,
sum(case when a.xbid in (select id from ryxx_bm_xbbm where id=2)
then 1 else 0 end) fn,
sum(case when a.dp_id in (select id from t_um_department where
gwybrs=1) then 1 else 0 end) dqgb,
round(avg(to_number(to_char(sysdate,'yyyy'))-to_number(substr
(a.csrq,1,4)))) pjnl,
sum(case when to_number(to_char(sysdate,'yyyy'))-to_number(substr
(a.csrq,1,4))<=35 then 1 else 0 end) nl35,
sum(case when (to_number(to_char(sysdate,'yyyy'))-to_number(substr
(a.csrq,1,4))>=36) and (to_number(to_char(sysdate,'yyyy'))
-to_number(substr(a.csrq,1,4))<=40) then 1 else 0 end) nl40,
sum(case when (to_number(to_char(sysdate,'yyyy'))-to_number(substr
(a.csrq,1,4))>=41) and (to_number(to_char(sysdate,'yyyy'))
-to_number(substr(a.csrq,1,4))<=45) then 1 else 0 end) nl45,
sum(case when (to_number(to_char(sysdate,'yyyy'))-to_number(substr
(a.csrq,1,4))>=46) and (to_number(to_char(sysdate,'yyyy'))
-to_number(substr(a.csrq,1,4))<=50) then 1 else 0 end) nl50,
sum(case when (to_number(to_char(sysdate,'yyyy'))-to_number(substr
(a.csrq,1,4))>=51) and (to_number(to_char(sysdate,'yyyy'))
-to_number(substr(a.csrq,1,4))<=55) then 1 else 0 end) nl55,
sum(case when to_number(to_char(sysdate,'yyyy'))-to_number(substr
(a.csrq,1,4))>=56 then 1 else 0 end) nl56,
sum(case when f.whcdid in (select id from ryxx_bm_whcd where
id<=8) then 1 else 0 end) yjs,
sum(case when f.whcdid in (select id from ryxx_bm_whcd where (id=9
or f_id=9)) then 1 else 0 end) dx,
sum(case when f.whcdid in (select id from ryxx_bm_whcd where
(id=23 or f_id=23)) then 1 else 0 end) dz,
sum(case when f.whcdid in (select id from ryxx_bm_whcd where
(id=37 or f_id=37)) then 1 else 0 end) zz,
sum(case when f.whcdid in (select id from ryxx_bm_whcd where
id>=47) then 1 else 0 end) gz,
0 jsj,0 gj,0 zj,0 zlj,0 yj
from t_um_user a,(select xzjbid,ryid from ryxx_gzjl where xzbs=1)
b,ryxx_bm_xzjb c,
(select zzmmid,ryid from ryxx_zzmm where xzbs=1) d,ryxx_bm_ryfl e,
(select whcdid,ryid from ryxx_xxjl where xzbs=1) f
where a.id=b.ryid(+) and b.xzjbid=c.id(+) and a.id=f.ryid(+) and
a.id=d.ryid(+) and a.ryflid=e.id(+) and substr(e.class,1,5)
='00001' and a.id<>1 +pltsrow.sid;
commit;
end loop;
close plts_cursor1;
end;
commit;
end;
编译的时候出现下列错误,sql没有问题 单独运行insert语句都正常
LINE 17 (5): PLS-00103: 出现符号 "CASE"在需要下列之一时:
(-+allmodnull
<an identifier><a double-quoted delimited-identifier>
<a bind variable>avgcountcurrentdistinctmaxminpriorsqlstddev
sumuniquevarianceexecuteforalltimetimestampintervaldate
<a string literal with character set specification>
<a number><a single-quoted SQL string>