而@@ Fetch_status = 0 开始 开始转运 申报费用游标 从co_rate_master中选择top 1 isnull(crm_course_rate,0),其中cmn_minor_code = @Keyword 和crm_active<>'D'和(datediff(d,crm_eff_start_dt,getdate())> = 0)和 (datediff(d,getdate(),crm_eff_end_dt)> = 0) 开放费用 取消费用到@Coursefees 而@@ Fetch_status = 0 开始 begin tran insert到#Temptable v alues(@ Batchdate,@ Coursefees) 从费用中取出来到@Coursefees 结束 关闭费用 deallocate费用 commit tran 从coursedate获取下一个@Batchdate end close coursedate deallocate coursedate commit tran close course deallocate course commit tran select * from #Temptable end 执行 exec [Keyword_Course_SMS]'AFF' 当我执行上面的商店程序错误如下 程序Keyword_Course_SMS,第50行 光标未打开。 程序Keyword_Course_SMS,第52行 COMMIT TRANSACTION请求没有相应的BEGIN TRANSACTION。 第50行如下 deallocate费用 第52行如下 从coursedate获取下一个@Ba tchdate 请帮我解决上面代码中的问题。 问候, Narasiman P My store procedure code as followsset ANSI_NULLS ONset QUOTED_IDENTIFIER ONGOALTER PROC [dbo].[Keyword_Course_SMS](@Keyword varchar(10))asbegindeclare @Batchdate varchar(20),@Coursefees moneycreate table #Temptable (Keyword varchar(10),coursename varchar(10)) begin trandeclare course cursor for select a.cmn_minor_code,b.Keyword from CO_MINOR_MASTER as a,Tb_Course_Keyword as b where a.cmn_minor_code = b.Keyword and b.Active <> 'D';declare coursedate cursor forselect top 1 isnull(crm_course_rate,0) from CO_BATCH_MASTERwhere cmn_minor_code = @Keywordand crm_active <>'D' and (datediff(d, crm_eff_start_dt, getdate()) >= 0) and (datediff(d, getdate(), crm_eff_end_dt) >= 0)open coursedate fetch next from coursedate into @Batchdatewhile @@Fetch_status = 0beginbegin tran declare fees cursor forselect top 1 isnull(crm_course_rate,0) from co_rate_master where cmn_minor_code = @Keywordand crm_active <>'D' and (datediff(d, crm_eff_start_dt, getdate()) >= 0) and (datediff(d, getdate(), crm_eff_end_dt) >= 0)open fees fetch next from fees into @Coursefeeswhile @@Fetch_status = 0beginbegin traninsert into #Temptable values(@Batchdate,@Coursefees)fetch next from fees into @Coursefeesend close feesdeallocate feescommit tranfetch next from coursedate into @Batchdateendclose coursedatedeallocate coursedatecommit tranclose coursedeallocate coursecommit transelect * from #TemptableendExecutionexec [Keyword_Course_SMS] 'AFF'When i execute the above store procedure Error as followsProcedure Keyword_Course_SMS, Line 50Cursor is not open.Procedure Keyword_Course_SMS, Line 52The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTION.Line 50 as followsdeallocate feesLine 52 as followsfetch next from coursedate into @Batchdateplease help me what is the problem in my above code.Regards,Narasiman P推荐答案 检查你的课程光标,它是不完整的。您已将其用于声明,但忘记打开并使用它。Check your 'course cursor' , It is Incomplete. You have used it for declaration but, forgot to open & use it. 这篇关于问题客栈我的商店proecdure代码如下的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
11-01 17:22