马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?站点注册
×
存储过程如下,老是提示end条件出错 CREATE PROCEDURE dbo.yyh_up_AppointTime(@i_Start_time varchar(10) = null,@i_End_time varchar(10) = null) as declare @Telephone varchar(20) declare @FirstReceptTime datetime declare @CorrectTime datetime declare @SubType varchar(1) declare @LineType varchar(1) declare @Random_num int declare @AppointTime datetime declare @TimeLimit1 int declare @TimeLimit2 int declare @Duration int declare @RepairOper varchar(8) declare @t1 char(2) declare @h1 int declare @o_h int declare @Corr_hour int ---declare @RepairTimeLimit int declare cur_tel1 cursor for select Telephone,FirstReceptTime,CorrectTime,SubType,LineType,RepairOper from tt_TTArchiveDay where FirstReceptTime >= @i_Start_time and FirstReceptTime < @i_End_time and LineType in ('A','X') and ComplaintSrc <> '10' open cur_tel1 fetch cur_tel1 into @Telephone,@FirstReceptTime,@CorrectTime,@SubType,@LineType,@RepairOper while @@sqlstatus<>2 begin select @Duration = datediff(mi,@FirstReceptTime,@CorrectTime) select @Corr_hour = convert(int,convert(char(2),@CorrectTime,108)) if (@SubType = '2' or @SubType = 'G') begin if (@Corr_hour>=8 and @Corr_hour<11) begin select @TimeLimit1 = convert(int,Rand()*(convert(int,Rand()*(convert(int,convert(char(2),CorrectTime,108))-8))+1)*60) end else if (@Corr_hour>=11 and @Corr_hour<22) begin select @TimeLimit1 = -((convert(int,Rand()*3 + 1)*60 end else begin select @TimeLimit1 = -((convert(int,Rand()*(@Corr_hour - 8)) + 1) end end else begin if (@Corr_hour>=8 and @Corr_hour<13) begin select @TimeLimit1 = convert(int,Rand()*(convert(int,Rand()*(convert(int,convert(char(2),CorrectTime,108))-8))+1)*60) end else if (@Corr_hour>=13 and @Corr_hour<22) begin select @TimeLimit1 = -((convert(int,Rand()*5 + 2)*60 end else begin select @TimeLimit1 = -((convert(int,Rand()*(@Corr_hour - 8)) + 1) end end end update tt_TTArchiveDay set AppointProcTime = @AppointTime,AppointTime = @AppointTime,AppointOper = @RepairOper,Duration = @Duration where Telephone = @Telephone and FirstReceptTime = @FirstReceptTime fetch cur_tel1 into @Telephone,@FirstReceptTime,@CorrectTime,@SubType,@LineType,@RepairOper end close cur_tel1 deallocate cursor cur_tel1
|