请教一个存储过程得用游标,好像进入死循环了,谢谢
CREATE PROCEDURE [dbo].[p_zdbk_crf5]
(
@xm VARCHAR(10)='客房',
@crcjfsj VARCHAR(8)='12:00:00', --次日加收半天费时间
@czy VARCHAR(10)='服务器',
@ccgcfhz INT OUTPUT, --存储过程返回值
@ccgcfhzms NVARCHAR(100) OUTPUT --存储过程返回值描述
)
AS
DECLARE @zdid VARCHAR(20)
DECLARE @gkid VARCHAR(20)
DECLARE @bh VARCHAR(10)
DECLARE @mc VARCHAR(10)
DECLARE @jrsj DATETIME
DECLARE @dzl DECIMAL
DECLARE @dze DECIMAL
DECLARE @cjffwxmid VARCHAR(10)
DECLARE @ycjfsj DATETIME
DECLARE @jffs VARCHAR(10)
SET @jffs=''
IF @dzl<>0 OR @dze<>0
SET @jffs='FPKDSZK'
--取超时宾客
DECLARE curZdbk CURSOR FOR
SELECT zdid,gkid,xm,bh,mc,jrsj,dzl,dze,cjffwxmid,ycjfsj FROM zdbkbdfwxm WHERE crcjf=1 AND crcjfsj=@crcjfsj --AND xm=@xm
OPEN curZdbk
FETCH NEXT FROM curZdbk
INTO @zdid,@gkid,@xm,@bh,@mc,@jrsj,@dzl,@dze,@cjffwxmid,@ycjfsj
WHILE (@@FETCH_STATUS=0)
BEGIN
DECLARE @yyrq DATETIME
SET @yyrq=CAST(CONVERT( VARCHAR(12) , GETDATE(), 102 ) AS DATETIME)
DECLARE @xfsj DATETIME
SET @xfsj=CAST(CONVERT( VARCHAR(12) , GETDATE(), 102 )+' '+@crcjfsj AS DATETIME)
DECLARE @yjtzjssj DATETIME
SET @yjtzjssj=DATEADD( DAY, 1 , CAST(CONVERT(VARCHAR(12) , GETDATE(), 102 )+' 12:00:00' AS DATETIME))
DECLARE @fl VARCHAR(10)
DECLARE @zl VARCHAR(10)
DECLARE @xmmc VARCHAR(30)
DECLARE @dw VARCHAR(2)
DECLARE @dj DECIMAL
DECLARE @sl DECIMAL
SET @sl=0.5
DECLARE @xj DECIMAL
DECLARE @ys DECIMAL
DECLARE @yxdz BIT
DECLARE @jzdz BIT
DECLARE @zdjr BIT
DECLARE @zdjs BIT
DECLARE @sc DECIMAL
DECLARE @tzjssl DECIMAL
DECLARE @djcpbm BIT
DECLARE @tcxm BIT
DECLARE @jsfw BIT
DECLARE @cpddy BIT
DECLARE @fjfw BIT
DECLARE @kgxm BIT
DECLARE @zsxm BIT
&nbs