各位帮忙看看这个存储过程那里错了?
<p>存储过程如下,老是提示end条件出错</p><p>CREATE PROCEDURE dbo.yyh_up_AppointTime(@i_Start_time varchar(10) = null,@i_End_time varchar(10) = null) <br/> as<br/>declare @Telephone varchar(20)<br/>declare @FirstReceptTime datetime<br/>declare @CorrectTime datetime<br/>declare @SubType varchar(1)<br/>declare @LineType varchar(1)<br/>declare @Random_num int<br/>declare @AppointTime datetime<br/>declare @TimeLimit1 int<br/>declare @TimeLimit2 int<br/>declare @Duration int<br/>declare @RepairOper varchar(8)<br/>declare @t1 char(2)<br/>declare @h1 int<br/>declare @o_h int<br/>declare @Corr_hour int<br/>---declare @RepairTimeLimit int</p><p>declare cur_tel1 cursor for <br/>select Telephone,FirstReceptTime,CorrectTime,SubType,LineType,RepairOper from tt_TTArchiveDay<br/>where FirstReceptTime >= @i_Start_time and FirstReceptTime < @i_End_time<br/>and LineType in ('A','X')<br/>and ComplaintSrc <> '10'</p><p>open cur_tel1<br/>fetch cur_tel1 into @Telephone,@FirstReceptTime,@CorrectTime,@SubType,@LineType,@RepairOper<br/>while @@sqlstatus<>2<br/>begin</p><p>select @Duration = datediff(mi,@FirstReceptTime,@CorrectTime)<br/>select @Corr_hour = convert(int,convert(char(2),@CorrectTime,108))</p><p>if (@SubType = '2' or @SubType = 'G')<br/>begin<br/> if (@Corr_hour>=8 and @Corr_hour<11)<br/> begin<br/> select @TimeLimit1 = convert(int,Rand()*(convert(int,Rand()*(convert(int,convert(char(2),CorrectTime,108))-8))+1)*60)<br/> end<br/> else if (@Corr_hour>=11 and @Corr_hour<22)<br/> begin<br/> select @TimeLimit1 = -((convert(int,Rand()*3 + 1)*60<br/> end<br/> else<br/> begin<br/> select @TimeLimit1 = -((convert(int,Rand()*(@Corr_hour - 8)) + 1)<br/> end<br/>end<br/>else<br/>begin<br/> if (@Corr_hour>=8 and @Corr_hour<13)<br/> begin<br/> select @TimeLimit1 = convert(int,Rand()*(convert(int,Rand()*(convert(int,convert(char(2),CorrectTime,108))-8))+1)*60)<br/> end<br/> else if (@Corr_hour>=13 and @Corr_hour<22)<br/> begin<br/> select @TimeLimit1 = -((convert(int,Rand()*5 + 2)*60<br/> end<br/> else<br/> begin<br/> select @TimeLimit1 = -((convert(int,Rand()*(@Corr_hour - 8)) + 1)<br/> end <br/> end <br/>end</p><p>update tt_TTArchiveDay set AppointProcTime = @AppointTime,AppointTime = @AppointTime,AppointOper = @RepairOper,Duration = @Duration where Telephone = @Telephone and FirstReceptTime = @FirstReceptTime<br/>fetch cur_tel1 into @Telephone,@FirstReceptTime,@CorrectTime,@SubType,@LineType,@RepairOper<br/>end<br/>close cur_tel1<br/>deallocate cursor cur_tel1<br/></p>
页:
[1]