请问那位能狗告诉我下面这个存储过程应该怎么改,它报表或视图不存在。procedure P_IBTalk
(
fromdate date,
enddate date,
grpno number,
incstep varchar2,
IBTalk out PG_HelpCenter.mycursor
)
as
currFrom date;
currEnd date;
grp number;
isql varchar2(5000);
dptable varchar2(100):='drop table QeryData';
begin
currFrom:=fromdate;
grp:=grpno;
execute immediate dptable;
isql:='Create global temporary Table QeryData(IOS number, agentid varchar2,agentgrp number,AnswerFlag number,
QueueDuration number,WaitTime number,StartRingTime date,TalkDuration number,
InboundCallTime DATE,InQueueTime DATE,HangUpTime date, DATE_PART VARCHAR2)on commit delete rows';
WHILE enddate > currFrom loop
BEGIN
if (incstep='1M') then
begin
currEnd:=DATEADD('M', 1, currFrom); --按月
end;
if (incstep='1W') then
begin
currEnd:=DATEADD('W', 1, currFrom); --按星期
end;
if (incstep='1D') then
begin
currEnd:=DATEADD('Day', 1, currFrom); --按天
end;
if (incstep='60m') then
begin
currEnd:=DATEADD('Hour', 1, currFrom); --按小时
end;
if (incstep='30m') then
begin
currEnd:=DATEADD('minute', 30, currFrom); --按半小时
end;
if (incstep='15m') then
begin
currEnd:=DATEADD('minute', 15, currFrom); --按15分钟
end;
if (incstep=''or incstep is null) then
begin
currEnd:=enddate;
end;
if grp is not null then
begin
execute immediate isql;
INSERT into QeryData
SELECT io,agentid,agentgrp,AnswerFlag,QueueDuration,WaitTime,StartRingTime,TalkDuration,
InboundCallTime,InQueueTime,HangUpTime,to_char(trunc(currFrom),'yyyy-mm-dd hh24:mi:ss')AS DATE_PART
FROM sno_calllog
WHERE InboundCallTime>=currFrom and InboundCallTime<currEnd and agentgrp=grp and agentid is not null
order by InboundCallTime,agentid;
end;
else
begin
execute immediate isql;
INSERT into QeryData
SELECT io,agentid,agentgrp,AnswerFlag,QueueDuration,WaitTime,StartRingTime,TalkDuration,
InboundCallTime,InQueueTime,HangUpTime,to_char(trunc(currFrom),'yyyy-mm-dd hh24:mi:ss')AS DATE_PART
FROM sno_calllog
WHERE InboundCallTime>=currFrom and InboundCallTime<currEnd and agentid is not null
order by InboundCallTime,agentid;
end;
end if;
end if;
end if;
end if;
end if;
end if;
end if;
end if;
currFrom:=currEnd; --进入下一阶段
end;
end loop;
open IBTalk for
select DATE_PART,sum(f1) as IBSum from
(
select DATE_PART,count(*)as f1 from QeryData where IOS=0
group by DATE_PART
)ss group by DATE_PART order by DATE_PART;
end P_IBTalk;
(
fromdate date,
enddate date,
grpno number,
incstep varchar2,
IBTalk out PG_HelpCenter.mycursor
)
as
currFrom date;
currEnd date;
grp number;
isql varchar2(5000);
dptable varchar2(100):='drop table QeryData';
begin
currFrom:=fromdate;
grp:=grpno;
execute immediate dptable;
isql:='Create global temporary Table QeryData(IOS number, agentid varchar2,agentgrp number,AnswerFlag number,
QueueDuration number,WaitTime number,StartRingTime date,TalkDuration number,
InboundCallTime DATE,InQueueTime DATE,HangUpTime date, DATE_PART VARCHAR2)on commit delete rows';
WHILE enddate > currFrom loop
BEGIN
if (incstep='1M') then
begin
currEnd:=DATEADD('M', 1, currFrom); --按月
end;
if (incstep='1W') then
begin
currEnd:=DATEADD('W', 1, currFrom); --按星期
end;
if (incstep='1D') then
begin
currEnd:=DATEADD('Day', 1, currFrom); --按天
end;
if (incstep='60m') then
begin
currEnd:=DATEADD('Hour', 1, currFrom); --按小时
end;
if (incstep='30m') then
begin
currEnd:=DATEADD('minute', 30, currFrom); --按半小时
end;
if (incstep='15m') then
begin
currEnd:=DATEADD('minute', 15, currFrom); --按15分钟
end;
if (incstep=''or incstep is null) then
begin
currEnd:=enddate;
end;
if grp is not null then
begin
execute immediate isql;
INSERT into QeryData
SELECT io,agentid,agentgrp,AnswerFlag,QueueDuration,WaitTime,StartRingTime,TalkDuration,
InboundCallTime,InQueueTime,HangUpTime,to_char(trunc(currFrom),'yyyy-mm-dd hh24:mi:ss')AS DATE_PART
FROM sno_calllog
WHERE InboundCallTime>=currFrom and InboundCallTime<currEnd and agentgrp=grp and agentid is not null
order by InboundCallTime,agentid;
end;
else
begin
execute immediate isql;
INSERT into QeryData
SELECT io,agentid,agentgrp,AnswerFlag,QueueDuration,WaitTime,StartRingTime,TalkDuration,
InboundCallTime,InQueueTime,HangUpTime,to_char(trunc(currFrom),'yyyy-mm-dd hh24:mi:ss')AS DATE_PART
FROM sno_calllog
WHERE InboundCallTime>=currFrom and InboundCallTime<currEnd and agentid is not null
order by InboundCallTime,agentid;
end;
end if;
end if;
end if;
end if;
end if;
end if;
end if;
end if;
currFrom:=currEnd; --进入下一阶段
end;
end loop;
open IBTalk for
select DATE_PART,sum(f1) as IBSum from
(
select DATE_PART,count(*)as f1 from QeryData where IOS=0
group by DATE_PART
)ss group by DATE_PART order by DATE_PART;
end P_IBTalk;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货