数据库游标

来源:百度知道 编辑:UC知道 时间:2024/05/09 03:21:32
declare tc2 SCROLL cursor for
select * from yx1
for update
open tc2

fetch next from tc2
while(@@fetch_status=0)
begin
update yx1 set age='2' where current of tc2
fetch next from tc2
end
close tc2
消息 16929,级别 16 状态 1,第 6 行
游标是只读的。
语句已终止。
错了为什么错
update yx1 set age='2' where current of tc2
这句花有错?????

你创建的这个表 yx1 没有主键或者unique约束,current of tc2 找不到。因此会报
消息 16929,级别 16 状态 1,第 6 行
游标是只读的。
这个错误。
改正这个错误 1.对这个表创建主键约束
2.更新条件 换做 楼上的 where 条件。

嗯,update yx1 set age='2' where current of tc2 有语法错误,用楼上的就可以修改
把declare tc2 SCROLL cursor for
select * from yx1
for update
的“for update ”去掉

应该是where 字段名=条件

of 是什么东西 我怎么没用到过呢
更新条件 update cardinfo set isreportloss='是'where cardid='1010 3576 1212 1134'