SQL中游标的用法
发布网友
发布时间:2022-05-02 19:51
我来回答
共4个回答
热心网友
时间:2022-05-02 21:21
在倒数第3行上面加上:fetch next from pcurr into @ID,@Sex
即:
......
set @Sexs = '男'
begin
update Person set Sex = @Sexs where ID = @ID
end
fetch next from pcurr into @ID,@Sex
end
close pcurr
deallocate pcurr
热心网友
时间:2022-05-02 22:39
if (@Sex = '1')
set @Sexs = '女'
else
set @Sexs = '男'
begin
update Person set Sex = @Sexs where ID = @ID
end
这个begin是多余的,end的位置是往上提,去掉就行了 、
if (@Sex = '1')
set @Sexs = '女'
else
set @Sexs = '男'
end
update Person set Sex = @Sexs where ID = @ID
热心网友
时间:2022-05-03 00:13
while 循环体的最后一行,应该加一句
fetch next from pcurr into @ID,@Sex
热心网友
时间:2022-05-03 02:05
在while循环体内 end前差一句 fetch next from pcurr into @ID,@Sex