ellsion 发表于 2006-11-27 18:11:30

各位帮忙看看这个存储过程那里错了?

<p>存储过程如下,老是提示end条件出错</p><p>CREATE PROCEDURE dbo.yyh_up_AppointTime(@i_Start_time varchar(10) = null,@i_End_time varchar(10) = null) <br/>&nbsp;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 &gt;= @i_Start_time and FirstReceptTime &lt; @i_End_time<br/>and LineType in ('A','X')<br/>and ComplaintSrc &lt;&gt; '10'</p><p>open cur_tel1<br/>fetch cur_tel1 into @Telephone,@FirstReceptTime,@CorrectTime,@SubType,@LineType,@RepairOper<br/>while @@sqlstatus&lt;&gt;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/>&nbsp;&nbsp;&nbsp; if (@Corr_hour&gt;=8 and @Corr_hour&lt;11)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select @TimeLimit1 = convert(int,Rand()*(convert(int,Rand()*(convert(int,convert(char(2),CorrectTime,108))-8))+1)*60)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br/>&nbsp;&nbsp;&nbsp; else if (@Corr_hour&gt;=11 and @Corr_hour&lt;22)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select @TimeLimit1 = -((convert(int,Rand()*3 + 1)*60<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br/>&nbsp;&nbsp;&nbsp; else<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select @TimeLimit1 = -((convert(int,Rand()*(@Corr_hour - 8)) + 1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br/>end<br/>else<br/>begin<br/>&nbsp;&nbsp;&nbsp; if (@Corr_hour&gt;=8 and @Corr_hour&lt;13)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select @TimeLimit1 = convert(int,Rand()*(convert(int,Rand()*(convert(int,convert(char(2),CorrectTime,108))-8))+1)*60)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br/>&nbsp;&nbsp;&nbsp; else if (@Corr_hour&gt;=13 and @Corr_hour&lt;22)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select @TimeLimit1 = -((convert(int,Rand()*5 + 2)*60<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end<br/>&nbsp;&nbsp;&nbsp; else<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; begin<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; select @TimeLimit1 = -((convert(int,Rand()*(@Corr_hour - 8)) + 1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; end <br/>&nbsp;&nbsp; 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]
查看完整版本: 各位帮忙看看这个存储过程那里错了?

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com