ALTER proc [dbo].[调用流程]
@BudgetType char(2)
,@Year numeric(4)
,@orgid nchar(10)
as
begin --1
declare @Productid varchar(8)
declare CallPrm Cursor for --建立游标
select ProductID from Product where productlevel is not null
or rtrim(ltrim((productlevel))) <>''
order by ProductLevel,Productid
for read only open CallPrm FETCH NEXT FROM CallPrm INTO @Productid
While @@fetch_status=0
begin --2
exec 成本计算主流程 @budgettype,@Productid,@year,1,@orgid
PRINT 'MONTH 1 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,2,@orgid
PRINT 'MONTH 2 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,3,@orgid
PRINT 'MONTH3 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,4,@orgid
PRINT 'MONTH4 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,5,@orgid
PRINT 'MONTH5 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,6,@orgid
PRINT 'MONTH6 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,7,@orgid
PRINT 'MONTH7 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,8,@orgid
PRINT 'MONTH8 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,9,@orgid
PRINT 'MONTH9 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,10,@orgid
PRINT 'MONTH10 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,11,@orgid
PRINT 'MONTH11 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,12,@orgid
PRINT 'MONTH12 SUCCESS.'
begin --3
FETCH NEXT FROM CallPrm INTO @Productid
end --3
end --2
close CallPro --关闭游标
DEALLOCATE CallPro --注销游标
end --1
这是一个存储过程,里面使用了游标来调用存储过程,但是执行提示错误如下:
Msg 16915, Level 16, State 1, Procedure 调用流程, Line 10
A cursor with the name 'CallPrm' already exists.
Msg 16905, Level 16, State 1, Procedure 调用流程, Line 15
The cursor is already open.
Msg 16916, Level 16, State 1, Procedure 调用流程, Line 50
A cursor with the name 'CallPro' does not exist.
Msg 16916, Level 16, State 1, Procedure 调用流程, Line 51
A cursor with the name 'CallPro' does not exist.我看着四条提示,前两条和后两条意思是完全相反的呀,大家帮忙看看是怎么回事。谢谢
@BudgetType char(2)
,@Year numeric(4)
,@orgid nchar(10)
as
begin --1
declare @Productid varchar(8)
declare CallPrm Cursor for --建立游标
select ProductID from Product where productlevel is not null
or rtrim(ltrim((productlevel))) <>''
order by ProductLevel,Productid
for read only open CallPrm FETCH NEXT FROM CallPrm INTO @Productid
While @@fetch_status=0
begin --2
exec 成本计算主流程 @budgettype,@Productid,@year,1,@orgid
PRINT 'MONTH 1 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,2,@orgid
PRINT 'MONTH 2 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,3,@orgid
PRINT 'MONTH3 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,4,@orgid
PRINT 'MONTH4 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,5,@orgid
PRINT 'MONTH5 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,6,@orgid
PRINT 'MONTH6 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,7,@orgid
PRINT 'MONTH7 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,8,@orgid
PRINT 'MONTH8 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,9,@orgid
PRINT 'MONTH9 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,10,@orgid
PRINT 'MONTH10 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,11,@orgid
PRINT 'MONTH11 SUCCESS.'
exec 成本计算主流程 @budgettype,@Productid,@year,12,@orgid
PRINT 'MONTH12 SUCCESS.'
begin --3
FETCH NEXT FROM CallPrm INTO @Productid
end --3
end --2
close CallPro --关闭游标
DEALLOCATE CallPro --注销游标
end --1
这是一个存储过程,里面使用了游标来调用存储过程,但是执行提示错误如下:
Msg 16915, Level 16, State 1, Procedure 调用流程, Line 10
A cursor with the name 'CallPrm' already exists.
Msg 16905, Level 16, State 1, Procedure 调用流程, Line 15
The cursor is already open.
Msg 16916, Level 16, State 1, Procedure 调用流程, Line 50
A cursor with the name 'CallPro' does not exist.
Msg 16916, Level 16, State 1, Procedure 调用流程, Line 51
A cursor with the name 'CallPro' does not exist.我看着四条提示,前两条和后两条意思是完全相反的呀,大家帮忙看看是怎么回事。谢谢
解决方案 »
- 请问在windows 7 professional 上面安装SQL 2008哪个版本可以?
- 如果需要了解sql server如何存储int型/datetime型的,那么请看
- 求一条SQL语句,谢谢!
- 请问高手:我想对一个可能存在多个空值列添加类似unique约束应该怎么办
- sql中比较字符串时,发现'A'与'a'是相等的.即'A'='a'为真,如何实现为假呀?
- 我有一个数据表格,我想得到下面的效果,如何做
- 请教一个我怎么都想不明白的问题,sql语句exec有关[在线等待,马上结贴]
- 关于远程访问win2003数据库的问题
- 如何让客户看不到数据库结构?
- 一个奇怪的现象,新插入的数据没有用到索引
- 小f妹妹 请
- 求sql语句
declare CallPrm Cursor for --建立游标
select ProductID from Product where productlevel is not null
or rtrim(ltrim((productlevel))) <>''
order by ProductLevel,Productid
for read only
建立游标
open CallPrm FETCH NEXT FROM CallPrm INTO @Productid --这里就是想用这个产品ID。循环调用存储过程“成本计算主流程 ”
DEALLOCATE CallPro
游标名错了