DECLAREcur_crzhsdCURSORFORSELECTcr.id,zh.id,zh.to_cnt,sd.sym,zh.time_stampFROMAHD.AHD.call_reqascrLEFTOUTERJOINAHD.AHD.ztr_hisaszhONcr.persid=zh.call_req_idLEFTOUTERJOINAHD.AHD.srv_descassdONcr.support_lev=sd.codeWHEREcr.type=Iandcr.open_date>@beginandcr.open_date<@endandzh.to_status=OP
OPENcur_crzhsd
FETCHcur_crzhsdINTO@cr_id,@zh_id,@cnt,@sym,@time_stamp
WHILE@@FETCH_STATUS=0
BEGIN
--get@handlethroughexecfgw_proc2
EXECfgw_proc4@zh_id,@sym,@time_stamp,@cntoutput,@isOKoutput
INSERTINTO#temp_proc3VALUES(@cr_id,@zh_id,@cnt,@isOK)
FETCHNEXTFROMcur_crzhsdINTO@cr_id,@zh_id,@cnt,@sym,@time_stamp
END
CLOSEcur_crzhsd
DEALLOCATEcur_crzhsd
SELECT*FROM#temp_proc3
DROPTABLE#temp_proc3
dropprocedurefgw_proc3
EXECfgw_proc31,1111111111
4,fgw_proc4
CREATEPROCEDUREfgw_proc4(@zh_idint,@levelchar(30),@time_stampint,@cntintOUTPUT,@isOKintOUTPUT)
AS
SETNOCOUNTON
SET@isOK=0
DECLAREcur_zhCURSORFORSELECTto_cnt,time_stampFROMAHD.AHD.ztr_hisWHEREid=@zh_idandto_statusin(L1WIP,L2WIP)andtime_stamp>@time_stamp
OPENcur_zh
DECLARE@time_stamp1int
SET@time_stamp1=0
FETCHcur_zhINTO@cnt,@time_stamp1
IF@time_stamp1!=0
BEGIN
IFCHARINDEX(一级,@level)ISNOTNULLANDCHARINDEX(一级,@level)!=0
BEGIN
if@time_stamp1-@time_stamp<600
SET@isOK=1
END
ELSEIFCHARINDEX(二级,@level)ISNOTNULLANDCHARINDEX(二级,@level)!=0
BEGIN
if@time_stamp1-@time_stamp<1800
SET@isOK=1
END
ELSEIFCHARINDEX(三级,@level)ISNOTNULLANDCHARINDEX(三级,@level)!=0
BEGIN
if@time_stamp1-@time_stamp<1800
SET@isOK=1
END
ELSEIFCHARINDEX(四级,@level)ISNOTNULLANDCHARINDEX(四级,@level)!=0
BEGIN
if@time_stamp1-@time_stamp<1800
SET@isOK=1
END
END