• 全部
  • 基础类
  • 应用实例
  • 新技术前沿

关于游标定义问题?

twenty 2004-03-01 12:54:05
存储过程:
CREATE proc kfly
(
@kbm nvarchar(20),
@sbm nvarchar(50),
@sl int,
@rq smalldatetime,
@dd nvarchar(2)
-- @retmsg char(30) output
)
as
declare @tmp0 int , @tmp1 int ,@tmp2 int
declare zkrst cursor scroll keyset scroll_locks for select sz_sy,sz_dj from kfsbzk where sz_sbm=@sbm and sz_dd=@dd and sz_sy > 0 order by sz_jkrq,sz_dj for update
begin transaction
update kfsbkc set sk_sl=sk_sl-@sl where sk_sbm=@sbm
if @@error <> 0
begin
--select @retmsg="修改库存表kfsbkc出错!"
rollback tran
return
end
delete from kfsbkc where sk_sl=0
if @@error <> 0
begin
--select @retmsg="清理表kfsbkc出错!"
rollback tran
return
end
open zkrst
fetch next from zkrst into @tmp0,@tmp1
if @@fetch_status <>0
begin
-- select "jjjjjjjjjjjjjjjjjjj"
rollback tran
return
end
while (@@fetch_status <> -1 )
begin
while ( @sl > 0)
begin
if @tmp0 >= @sl
begin
insert into kfsbly (sl_kbm,sl_sbm,sl_sl,sl_rq,sl_bf,sl_db,sl_gh,sl_dj,sl_dd) values ( @kbm,@sbm,@sl,@rq,0,0,0,@tmp1,@dd)
if @@error <> 0
begin
-- select @retmsg="入表kfsbly出错!"
rollback tran
return
end
select @tmp0 = @tmp0 - @sl
update kfsbzk set sz_sl=@tmp0 where current of zkrst
if @@error <> 0
begin
-- select @retmsg="修改总训出错"
rollback tran
return
end
end
else
begin
insert into kfsbly (sl_kbm,sl_sbm,sl_sl,sl_rq,sl_bf,sl_db,sl_gh,sl_dj,sl_dd) values ( @kbm,@sbm,@sl,@rq,0,0,0,@tmp1,@dd)
if @@error <> 0
begin
-- select @retmsg="入表kfsbly出错!"
rollback tran
return
end
select @sl= @sl - @tmp0
select @tmp0=0
update kfsbzk set sz_sl=@tmp0 where current of zkrst
if @@error <> 0
begin
-- select @retmsg="修改总训出错"
rollback tran
return
end
fetch next from zkrst into @tmp0,@tmp1
end
end
end
update kbm set kb_ly=kb_ly+1 where kb_kbm = @kbm
if @@error <> 0
begin
-- select @retmsg="修改KBM训出错"
rollback tran
return
end
update kbm set kb_ly=0 where kb_ly >= 20 and kb_kbm=@kbm
if @@error <> 0
begin
-- select @retmsg="修改KBM训出错"
rollback tran
return
end
commit tran
if @@error <> 0
begin

--select @retmsg= "提交事务错!"
rollback tran
return
end
GO

当执行exec kfly '飞奔','4450587805',9,'2004-02-25','九楼'时提示游标类型为read only,不能使用update,why?????
登录用户:sa
...全文
24 点赞 收藏 回复
写回复
回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复

还没有回复,快来抢沙发~

相关推荐
发帖
MS-SQL Server
创建于2007-09-28

3.3w+

社区成员

MS-SQL Server相关内容讨论专区
申请成为版主
帖子事件
创建了帖子
2004-03-01 12:54
社区公告
暂无公告