存储过程---实践

<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

1,fgw_proc1:


CREATEPROCEDUREfgw_proc1(@beginint,@endint)
AS

   SETNOCOUNTON
   DECLARE@useridint,@handledfloat,@totalfloat

   CREATETABLE#temp_proc1
   (
   useridint,
   handledfloat,
   totalfloat
   )
   --get@total
   DECLAREcur_crCURSORFORSELECTcount(*)FROMAHD.AHD.call_reqwhereopen_date>@beginandopen_date<@end
   OPENcur_cr
   FETCHcur_crINTO@total
   CLOSEcur_cr
   DEALLOCATEcur_cr
   
   DECLAREcur_ctctCURSORFORSELECTidFROMAHD.AHD.ctct
   OPENcur_ctct
   FETCHcur_ctctINTO@userid
   WHILE@@FETCH_STATUS=0
       BEGIN
 --get@handlethroughexecfgw_proc2
 EXECfgw_proc2@userid,@begin,@end,@handledoutput
       INSERTINTO#temp_proc1VALUES(@userid,@handled,@total)
 FETCHNEXTFROMcur_ctctINTO@userid
       END
   CLOSEcur_ctct
   DEALLOCATEcur_ctct
   SELECT*FROM#temp_proc1
   DROPTABLE#temp_proc1


dropprocedurefgw_proc1
execfgw_proc11,1


2,fgw_proc2

CREATEPROCEDUREfgw_proc2(@useridint,@beginint,@endint,@handledfloatOUTPUT)
AS

   SETNOCOUNTON
   SET@handled=0
   DECLARE@cr_idint,@zh_idint,@statuschar(20),@to_statuschar(20),@cntint,@open_dateint
   DECLAREcur_crzhCURSORFORSELECT*FROMAHD.dbo.FGW_CR_ZHwherecnt=@userid
   OPENcur_crzh
   FETCHcur_crzhINTO@cr_id,@zh_id,@status,@to_status,@cnt,@open_date
   WHILE@@FETCH_STATUS=0
       BEGIN
 DECLARE@count2int
       DECLAREcur_crzh2CURSORFORSELECTcount(*)FROMAHD.dbo.FGW_CR_ZHwherecr_id=@cr_idandopen_date>@beginandopen_date<@end
 OPENcur_crzh2
 FETCHcur_crzh2INTO@count2
 CLOSEcur_crzh2
 DEALLOCATEcur_crzh2
 IF@count2!=0
  SET@handled=@handled+1/@count2
 FETCHNEXTFROMcur_crzhINTO@cr_id,@zh_id,@status,@to_status,@cnt,@open_date
       END
   CLOSEcur_crzh
   DEALLOCATEcur_crzh
   --SELECT@handled

 

dropprocedurefgw_proc2
execfgw_proc21,1,1

3,fgw_proc3


CREATEPROCEDUREfgw_proc3(@beginint,@endint)
AS

   SETNOCOUNTON
   DECLARE@cr_idint,@zh_idint,@cntint,@symchar(30),@time_stampint,@isOKint

   CREATETABLE#temp_proc3
   (
   cr_idint,
   zh_idint,
   cntint,共2页  第1页 
<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值