的存储过程
作者: 官方时时彩app下载-数据库 发布:2019-11-16
下边包车型大巴见解是在应用游标的进度中做的日志。作者也是第一回接纳,如果有什么狼狈之处请商量指正,大家一起尽力。
1.
消息 16951,级别 16,状态 1,过程
usp_proc,第 16 行
变量 '@myref'
不能用作参数,因为在推行该进度前,不得为 CU锐界SO纳瓦拉 OUTPUT
参数分配游标。
那几个主题素材是自己在调用八个递归的、输出cursor output 的积存进程
create proc usp_proc(
@level int
@myref cursor varying output
)
as
begin
if @level=3
begin
set @myref=cursor local static for
select * from table
open @myref
end
if @level<3
begin
declare @cur cursor
exec usp_proc 2 @cur output --递归
--
--对输出游标@cur做一些操作
--
--使用完游标
close @cur --关闭游标
deallocate @cur --删除游标
end
end
倘诺未有对出口的游标做close、deallocate管理就能够鬼使神差上边错误。
2.
未有为@cur,分配游标
那个难点是笔者在选拔存储进程再次来到的游标 cursor output 产生的
create proc myproc(
@mycur cursor varying output
)
as
begin
set @mycur=cursor local static for
select * from table
open @mycur --打开游标
end
--调用myproc
declare @cur cursor
exec myproc @cur output
fetch next from @cur
while @@fetch_status=0
begin
--使用游标
fetch next from @cur
end
并发上述错的原故正是概念游标后须要开辟 open @mycur
本文由时时彩平台发布于官方时时彩app下载-数据库,转载请注明出处:的存储过程
关键词:
上一篇:查询各分类中最大自增ID
下一篇:没有了
下一篇:没有了