oracle存储过程、游标参考实例
create or replace procedure INIT_DICT_QUEUECODE(p_queueId int,p_paramType in varchar2,p_queenName in varchar2,p_ofDepart in varchar2,p_result out int)
is
loopNum number;--循环次数
codeNum number;--号源编号
codeFirstAm number;
codeFirstPm number;
cursor paramDetails is select queuename,paramtype,begintimepart,endtimepart,ofdepart,calltype,codecount from qs_param a where a.queueid=p_queueId and a.paramtype=p_paramType order by to_number(endtimepart); c_row paramDetails%rowtype;
begin
loopNum:=1;
codeNum:=1;
codeFirstAm:=0;--未进⾏初始化
codeFirstPm:=0;--未进⾏初始化
--删除号源字典
delete from dict_queuecode b where b.queuename=p_queenName deparamtype=p_paramType and b.ofdepart=p_ofDepart;
FOR c_row IN paramDetails LOOP
--循环获取qs_param表中维护的某个时间段
loopNum:=1;
while loopNum <= decount loop
if codeFirstAm=0 and c_row.calltype='上午' then
oracle游标的使用codeNum:=1;
codeFirstAm:=1;
end if;
if codeFirstPm=0 and c_row.calltype='下午' then
codeNum:=1;
codeFirstPm:=1;
end if;
insert into DICT_QUEUECODE t (t.devalue,t.timepart,t.hintinfo,t.OFDEPART,t.calltype,t.queueid)
values (c_row.queuename,c_row.paramtype,codeNum,c_row.begintimepart||'~'||dtimepart,'',c_row.ofdepart,c_row.calltype,p_queueId);
loopNum:=loopNum+1;
codeNum:=codeNum+1;
end loop;
END LOOP;
p_result:=1;
commit;
EXCEPTION
when others then
p_result:=-1;
rollback;
end;
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论