标题:小小菜鸟向大家请教一个问题
只看楼主
七月流火
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-2-28
 问题点数:0 回复次数:1 
小小菜鸟向大家请教一个问题

小小菜鸟向大家请教一个问题
能告诉我这段代码里面究竟出了什么问题吗
本算法的目的:根据表中的 post_value 字段找出符合条件的记录
谢谢大家了!
declare t_media_post_cursor cursor for
select post_id,post_mobilenum,post_value
from t_media_post
open t_media_post_cursor
go
declare @count int(1),@i int(3),@subvalue varchar(5)
declare @post_id int(3),@post_mobilenum varchar(15),@post_value varchar(255)
set @count=0
set @i=0
fetch next from t_media_post_cursor
into @post_id,@post_mobilenum,@post_value
while @@fetch_status <> -1
begin
while @count<=3
begin
@subvalue=substr(@post_value,1,@i)
if @subvalue not in ('A','C','D','F','G','H','K','L')
@count=@count+1
@i=@i+1
end if
end
if @count<3
print ' @post_id,@post_mobilenum,@post_value'
end if
fetch next from t_media_post_cursor
into @post_id,@post_mobilenum,@post_value
end
close t_media_post_cursor
DEALLOCATE t_media_post_cursor

搜索更多相关主题的帖子: 小菜 
2006-06-07 10:54
weizy
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-8-1
得分:0 
while @count<=3
begin
@subvalue=substr(@post_value,1,@i)
if @subvalue not in ('A','C','D','F','G','H','K','L')
@count=@count+1
@i=@i+1
end if
end
这里if 一旦为True时, i和count都不变了, 可能会造成死循环吧, 最好对if加个else 做跳出while处理
2006-08-01 15:08



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-70312-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.450737 second(s), 8 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved