EXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配。上一计数 = 1,当前计数 = 0。

第二个错误是怎么出现的???
过程如下:

 CREATE
 proc [dbo].[GetSerialNum] @type varchar(32),@serialNum varchar(32) output
as
begin 
    if(isnull(@type,'')='')
    begin
        raiserror('序列号类型不能为空',16,1)
    end
    begin try
    begin tran
                    raiserror('自爆',16,1)
                    --DO SOMTTHING
                    commit tran
    end try
    begin catch
            rollback tran
            declare @msg varchar(max)
            set @msg=ERROR_MESSAGE()
            raiserror(@msg,16,1)
    end catch
end

调用语句如下:

 begin tran
                declare @recnum varchar(32)
                exec [GetSerialNum] 'orderSerialNum',@recnum output
                print @recnum
if @@TRANCOUNT>0
begin 
                commit tran
end

错误如下:图片说明

sql

1个回答

这个说明你的序列号的获取不匹配

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
其他相关推荐
EXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配。上一计数 = 0,当前计数 = 1。
执行事务报错: Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMIT statements. Previous count = 1, current count = 0 翻译: EXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配。上一计
EXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配。上一计数 = 3,当前计数 = 0。
--判断此方案是否已流产,如流产给用户退钱rnalter proc SP_Buymoneyrn@schemenumber varchar(50),rn@sysusername varchar(50),rn@percent decimal(18,2), --要除去的百分比的钱rn@queshstate tinyint , --方案表中的撤单状态rn@sysdealtype TinyInt, --网站系统保底的交易类型rn@dealtype TinyInt --交易类型rnasrnbeginrn--开始事务rn declare @intErrorCode intrn declare @isweb decimal(18,2)rn declare @userid_system intrn declare @sysBlance moneyrn declare @rebuymoney_self money --方案发起人跟单的钱rn declare @rebuymoney_with money --方案跟单人的钱rn declare @selfblance money --用户账上的余额rn declare @withmoney money --跟单人的钱rn declare @count int --跟单人数量rn declare @i int=0rn declare @BuyDetailID int --跟单人idrn declare @RelatedUserID int --跟单用户useridrn begin tryrn begin transactionrn select @intErrorCode=@@ERROR --每执行一次任务,接收一次错误信息rn declare @selfmoney money--自购金额rn declare @amout money--购买的总金额rn declare @together money --跟单人总金额 rn select @selfmoney=BuyedMoney from T_Scheme where SchemeNumber=@schemenumberrn select @together=sum(Price) from T_BuyDetails where SchemeNumber=@schemenumber--跟单人的总金额rn set @amout=@together+@selfmoney--已购买总金额rn print @amout --已购买总金额rn declare @money money--方案总金额rn declare @result money --所差金额rn select @money=BuyMonery from T_Scheme where SchemeNumber=@schemenumber rn set @result=@money-@amout --610 --所差金额rn print @result rn 。rn declare @diff money rn declare @userid intrn declare @freeze moneyrn declare @vacany money --最终空缺的钱。rn declare @diffmoney money --标记变量用于退款rn select @diff=AssureMonery from T_Scheme where SchemeNumber=@schemenumber --保底的钱rn print @diffrn select @userid=UserID from T_Scheme where SchemeNumber=@schemenumberrn print @useridrn select @freeze=Freeze from T_Users where UserID=@useridrn print @freezern if(@result>=@diff) --空缺所差的钱大于或等于保底金额 rn beginrn set @amout=@amout+@diff --加上保底后已买的总金额rn select @intErrorCode=@@ERROR rn set @vacany=@result-@diff --最终空缺的钱(加上保底后还差的钱)。rn print @vacanyrn select @intErrorCode=@@ERROR rn endrn else --保底的钱大于所差的钱。rn begin rn set @amout=@amout+@result rn ---所有购买方案的钱(加上保底的)rn print @amout rn select @intErrorCode=@@ERROR rn endrn declare @Demwer intrn select @userid_system=UserID from T_Users where Username=@sysusernamern if(@money<=@amout)rn beginrn --可以出票了rn set @vacany=0 ---表示不方案总金额与购买金额这间不差钱rn set @Demwer=0rn update T_Scheme set IsFullCommission=1,QuashStatus=0 where @money<=@amout and SchemeNumber=@schemenumber --可以出票把是否满员:改为已满员 未撤单rn ---已满员。把用户购买彩票的钱从冻结金额里面减去,加到系统账户余额里面。rn if(@result>=@diff)rn beginrn update T_Users set Freeze=Freeze-@diff-@selfmoney where UserID=@userid --冻结金额减去空缺的保底钱 减去自购的钱rn set @diffmoney=@diffrn endrn elsern beginrn update T_Users set Freeze=Freeze-@result-@selfmoney,Balance=Balance+(@diff-@result) where UserID=@userid --冻结金额要减去空缺保底的钱,把多余的钱退还给用户rn set @diffmoney=@result --从保底中减去的钱rn endrn --(加上保底后已够方案总金额:满员)发起人跟系统加钱rn update T_Users set Balance=Balance+@selfmoney+@diffmoney where Username=@sysusername rn select @sysBlance=Balance from T_Users where UserID=@userid_systemrn insert into T_UserDealDetails(UserID,DealType,DetailMoney,SchemeNumber,RelatedUserID,NonceBalance)rn values(@userid_system,@sysdealtype,@vacany,@schemenumber,@userid,@sysBlance)rn --(加上保底后已够方案总金额:满员)跟单人给系统加钱rn select @count= COUNT(ID) from T_BuyDetails where SchemeNumber=@schemenumberrn print @countrn set @i=0rn while(1=1)rn begin rn select @BuyDetailID=ID from T_BuyDetails where id = (select top 1 ID from T_BuyDetails where id not in (select top (@i) ID from T_BuyDetails where SchemeNumber=@schemenumber) and SchemeNumber=@schemenumber)rn select @RelatedUserID=UserID from T_BuyDetails where id = (select top 1 ID from T_BuyDetails where id not in (select top (@i) ID from T_BuyDetails where SchemeNumber=@schemenumber) and SchemeNumber=@schemenumber)rn select @withmoney=Price from T_BuyDetails where ID=@BuyDetailIDrn rn declare @c money rn select @c= Freeze from T_Users where UserID=@RelatedUserIDrn if (@c-@withmoney)<=0rn beginrn breakrn endrn print convert(varchar(20),@c)+'-'+convert(varchar(20),@withmoney)+'='+convert(varchar(20),(@c-@withmoney))rn --update T_Users set Freeze=Freeze-@withmoney where UserID=@RelatedUserIDrn rn set @selfblance=0rn select @selfblance=Balance from T_Users where UserID=@RelatedUserIDrn insert into T_UserDealDetails (UserID,DealType,DetailMoney,SchemeNumber,RelatedUserID,NonceBalance)rn values(@RelatedUserID,@dealtype,@withmoney,@schemenumber,@userid,@selfblance)rn --print @BuyDetailIDrn --print('delete T_BuyDetails where UserID='+@RelatedUserID+' and SchemeNumber='''+@schemenumber+''' and ID='+@BuyDetailID+'')rn print 'd-e'rn --print 'delete T_BuyDetails where UserID='+@RelatedUserID+' and SchemeNumber='+@schemenumber+' and ID='+@BuyDetailID+''rn set @i=@i+1rn if @i=@countrn beginrn returnrn end rn print @i rn end rn endrn
EXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配。上一计数 = 1,当前计数 = 2。
[code=SQL][/code]rn--判断要创建的存储过程是否存在,如果存在就先删除rnif exists(select * from sysobjects where name='usp_insert')rndrop proc usp_insertrngorncreate proc usp_insertrn@identityid char(18), --身份证号rn@guesname varchar(50), --客人姓名rn@roomid int, --房间编号rn@resideDate datetime, --入住日期rn@deposit money=1000, --押金rn@guestid int output --客人表最后一个编号rnasrn--开始事务rnbegin transactionrndeclare @error int=0rn--判断身份证号是否为18位rnif(LEN(@identityid)<>18)rnset @error=@error+@@Errorrnreturn -1rn--把信息插入到客人表rninsert into GuestRecord(IdentityID,GuestName,RoomID,ResideID,ResideDate,Deposit) values(@identityid,@guesname,@roomid,1,@resideDate,@deposit)rnset @error=@error+@@ERRORrnif(@error<>0)rnreturn -1rndeclare @roomStateId varchar(20) --记录入住状态的编号rnset @roomStateId=(select RoomStateId from RoomState where RoomStateName='已入住')rn--更新房间表rnupdate Room set GuestNum=guestNum+1,RoomStateID=@roomStateId where RoomID=@roomidrnset @error=@error+@@ERRORrnif(@error<>0)rnbeginrnrollback transaction --回滚事务rnreturn -1rnendrnelsernbeginrn--得到客人表最后一个编号rnselect @guestid=@@IDENTITY from GuestRecordrncommit transaction --提交事务rnendrnGo
对象名 'Operated' 无效。 EXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配。上一计数 = 0,当前计数 = 1。
对象名 'Operated' 无效。 EXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配。上一计数 = 0,当前计数 = 1。 这是什么原因啊??? 哪位大神指导啊?
EXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配。上一计数 = 0,当前计数 = 1。 怎么结局,求大神解答!!
ALTER PROCEDURE [dbo].[pro_outstore666]rn (rn @rpcode VARCHAR(20) ,rn @cad VARCHAR(20),rn @saleaddress VARCHAR(100) ,rn @od VARCHAR(20) ,--出库日期rn @WHCode VARCHAR(20) ,--仓库编码rn @QTY INT ,--数量rn @spmark INT , --标示rn @tssm VARCHAR(500) , --特殊说明rn @opcode VARCHAR(20) ,rn --@ShGoogcode VARCHAR(20),rn rn @batchnum VARCHAR(20) ,rn @batchcout INTrn rn )rnAS /*****************************************/rn DECLARE @iErrorCount INT,@TranCount INT;rn rn SET @iErrorCount = @@TranCount;rn rn IF @iErrorCount > 0 rn SAVE TRANSACTION ProcedureSavern ELSE rn rn BEGIN TRAN Tran_out;rn rn/****************************************/rn DECLARE @storeID INT ,rn @outID INT;rn SELECT @storeID = idrn FROM dbo.BaseStorern WHERE Basecode = @WHCode;rn BEGIN rn rn rn rn IF EXISTS ( SELECT TOP 1rn 1rn FROM dbo.stock_storckrn WHERE stockID = @storeIDrn AND stockNum >= @QTYrn AND rpcode = @rpcode )rn BEGINrn UPDATE dbo.stock_storckrn SET stockNum = stockNum - @QTY ,rn datechange = GETDATE()rn WHERE rpcode = @rpcodern AND stockID = @storeID;rn SET @iErrorCount = @iErrorCount + @@error;rn INSERT INTO dbo.outproductrn ( rpcode ,rn OD ,rn WHcode ,rn QTY ,rn spmark ,rn TSNote ,rn usercode ,rn WH ,rn statustype ,rn INbatch ,rn batchCount ,rn CAD,rn saleaddressrn )rn VALUES ( @rpcode ,rn @od ,rn @WHCode ,rn @QTY ,rn @spmark ,rn @tssm ,rn @opcode ,rn @storeID ,rn '直接出库' ,rn @batchnum ,rn @batchcout,rn @cad,rn @saleaddressrn );rn rn SET @iErrorCount = @iErrorCount + @@error;rn SET @outID = @@identity; --入库明细id rn rn rn INSERT INTO dbo.sys_storelogrn ( log_name ,rn outID ,rn logtype ,-- 0 表示入 1表示出库rn storenum ,rn storeID ,rn storeWh ,rn isdel ,rn log_datetime ,rn log_opname ,rn rpcodern )rn VALUES ( '直接出库' ,rn @outID ,rn 1 ,rn @QTY ,rn @storeID ,rn @WHCode ,rn 0 ,rn GETDATE() ,rn @opcode ,rn @rpcodern );rn SET @iErrorCount = @iErrorCount + @@error;rn IF @iErrorCount = 0rn BEGIN rn COMMIT TRAN Tran_out;rn END; rn ELSErn BEGIN rn ROLLBACK TRAN Tran_out;rn END; rn END;rnrn rn END;rn
EXECUTE 后的事务计数指示缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。上一计数 = 0,当前计数 = 1。分析...
ALTER PROCEDURE [dbo].[cor_InsertServerConfig] ( @ServerName varchar(20), @ServerIP varchar(20), @ServerCategory varchar(25), @ServerState  char(1), @ServerAbility int --@ID  int output    ) AS DECLA...
sql中出现错误:EXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配。
消息 266,级别 16,状态 2,过程 e_OperationInform,第 47 行rnEXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配。上一计数 = 2,当前计数 = 3rn代码如下,请高人帮忙看看rnALTER PROCEDURE [dbo].[e_OperationInform]rn @UserName varchar(50),rn @pramXml Textrn --@Result char(1) OUTPUT -- 返回结果rnASrnBEGINrn DECLARE @idoc intrn DECLARE @examName varchar(800)rn DECLARE @limitMins varchar(800)rn DECLARE @neecCheck varchar(800)rn DECLARE @needPrompt varchar(800)rn DECLARE @setAnswer varchar(800)rn DECLARE @beginDate varchar(800)rn DECLARE @endDate varchar(800)rn DECLARE @paperId varchar(800)rn rn DECLARE @exemId intrn rn EXEC sp_xml_preparedocument @idoc OUTPUT,@pramXml rnrn set @paperId = (SELECT * FROM OPENXML (@idoc,'/xml/PaperId',1) WITH (name varchar(4000))) rn set @examName = (SELECT * FROM OPENXML (@idoc,'/xml/ExamName',1) WITH (name varchar(4000))) rn set @limitMins = (SELECT * FROM OPENXML (@idoc,'/xml/LimitMins',1) WITH (name varchar(4000))) rn set @neecCheck = (SELECT * FROM OPENXML (@idoc,'/xml/NeecCheck',1) WITH (name varchar(4000))) rn set @needPrompt = (SELECT * FROM OPENXML (@idoc,'/xml/NeedPrompt',1) WITH (name varchar(4000))) rn set @setAnswer = (SELECT * FROM OPENXML (@idoc,'/xml/SetAnswer',1) WITH (name varchar(4000))) rn set @beginDate = (SELECT * FROM OPENXML (@idoc,'/xml/BeginDate',1) WITH (name varchar(4000))) rn set @endDate = (SELECT * FROM OPENXML (@idoc,'/xml/EndDate',1) WITH (name varchar(4000)))rn rn INSERT INTO dbo.ExamInfo(ExamName,PaperId,[Status],LimitMins,BeginDate,EndDate,NeecCheck,NeedPrompt,SetAnswer,CreateUser) values(@examName,@paperId,2,@limitMins,@beginDate,@endDate,@neecCheck,@needPrompt,@setAnswer,@UserName)rn set @exemId = @@IDENTITY rn SELECT * into #tmp FROM OPENXML (@idoc,'/xml/Cs',1) WITH (ClassId int,StudentId int) rn EXEC sp_xml_removedocument @idocrnrn IF(@exemId > 0)rn BEGIN rn BEGIN TRANSACTION rn INSERT INTO ExamParperStatus ([ExamId],[ClassId],[StId],[Status],[IsCheck],[CheckTeach],[CreateUser])rn SELECT @exemId,t.ClassId,(t.StudentId),0,@neecCheck,@UserName,@UserName FROM #tmp trn rn INSERT INTO ExamQuestionStatus([StudId],[ExamId],[PaperId],[QuestionId],[SubjectId],[CreateUser])rn SELECT m.StudentIdd,@exemId,@paperId,e.QuesId,e.SubjectId,@UserName FROM #tmp m, ExamQuestion e WHERE e.PaperId = @paperIdrn --上面的sql语句报错的话就不走下面代码rn IF @@ERROR <> 0rn BEGINrn ROLLBACK TRANSACTIONrn ENDrn ELSErn BEGINrnrn COMMIT TRANSACTIONrn ENDrn EndrnENDrn
EXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配
请大家给看下以下存储过程为啥会抱错,谢谢!rn[code=SQL]rncreate procedure HR_TransPosern@condition varchar(200),@grouptype intrnAS rnrnDECLARE @errorSun INT --定义错误计数器rnSET @errorSun=0 --没错为0rnexec('select * into ##Elearning1 from Elearning_AnswerSheet where' + @condition)rnrndeclare @sql varchar(8000)rnselect @sql = isnull(@sql + '],[' , '') + Class from ##Elearning1 group by Class rnset @sql = '[' + @sql + ']'rnexec ('select m.* , n.平均分 into ##Elearning2 fromrn(select * from (select TopicID,Store,Name,Position,Code,Mark,Class from ##Elearning1) a pivot (AVG(Mark) for Class in (' + @sql + ')) b) m , rn(select TopicID,Store,Name,Code,Position,cast(avg(Mark*1.0) as decimal(18,2)) as 平均分 from ##Elearning1 group by TopicID,Store,Name,Code,Position) nrnwhere m.Store = n.Store and m.Name=n.Name and m.Code=n.Code and m.Position=n.Position')rnrnBEGIN TRANSACTIONrnBeginrnif (@grouptype=1)rnbeginrnDelete from Elearning_AnswerSheet_NamernSET @errorSun=@errorSun+@@ERROR --累计是否有错rnInsert into Elearning_AnswerSheet_Name(TopicID,Store,Name,Position,Code,ldxs,sysfw,shfw,whzh,xsqq,xszq,ygyryb,ztgs,pjf) SELECT TopicID,Store,Name,Position,Code,连带销售,试衣室服务,售后服务,[问候/招呼],销售前期,销售中期,员工仪容仪表,整体感受,平均分 FROM ##Elearning2 rnSET @errorSun=@errorSun+@@ERROR --累计是否有错rnUPDATE Elearning_AnswerSheet_Name SET TopicName=(select Name from Elearning_Topics where Elearning_AnswerSheet_Name.TopicID=Elearning_Topics.TopicID)rnSET @errorSun=@errorSun+@@ERROR --累计是否有错rnendrnelse if (@grouptype=2)rnbeginrnDelete from Elearning_AnswerSheet_StorernSET @errorSun=@errorSun+@@ERROR --累计是否有错rnINSERT INTO Elearning_AnswerSheet_Store(TopicID,Store,Code,ldxs,sysfw,shfw,whzh,xsqq,xszq,ygyryb,ztgs,pjf) SELECT TopicID,Store,Code,连带销售,试衣室服务,售后服务,[问候/招呼],销售前期,销售中期,员工仪容仪表,整体感受,平均分 FROM ##Elearning2 group by TopicID,Store,Code,连带销售,试衣室服务,售后服务,[问候/招呼],销售前期,销售中期,员工仪容仪表,整体感受,平均分rnSET @errorSun=@errorSun+@@ERROR --累计是否有错rnUPDATE Elearning_AnswerSheet_Store SET TopicName=(select Name from Elearning_Topics where Elearning_AnswerSheet_Store.TopicID=Elearning_Topics.TopicID)rnSET @errorSun=@errorSun+@@ERROR --累计是否有错rnendrnelse if (@grouptype=3)rnbeginrnDelete from Elearning_AnswerSheet_LocationrnSET @errorSun=@errorSun+@@ERROR --累计是否有错rnINSERT INTO Elearning_AnswerSheet_Location(TopicID,Location,Code,ldxs,sysfw,shfw,whzh,xsqq,xszq,ygyryb,ztgs,pjf) SELECT TopicID,substring(Store,2,2),Code,连带销售,试衣室服务,售后服务,[问候/招呼],销售前期,销售中期,员工仪容仪表,整体感受,平均分 FROM ##Elearning2 group by TopicID,substring(Store,2,2),Code,连带销售,试衣室服务,售后服务,[问候/招呼],销售前期,销售中期,员工仪容仪表,整体感受,平均分rnSET @errorSun=@errorSun+@@ERROR --累计是否有错rnUPDATE Elearning_AnswerSheet_Location SET TopicName=(select Name from Elearning_Topics where Elearning_AnswerSheet_Location.TopicID=Elearning_Topics.TopicID)rnSET @errorSun=@errorSun+@@ERROR --累计是否有错rnendrnelse if (@grouptype=4)rnbeginrnDelete from Elearning_AnswerSheet_TopicrnSET @errorSun=@errorSun+@@ERROR --累计是否有错rnINSERT INTO Elearning_AnswerSheet_Topic(TopicID,Code,ldxs,sysfw,shfw,whzh,xsqq,xszq,ygyryb,ztgs,pjf) SELECT TopicID,Code,连带销售,试衣室服务,售后服务,[问候/招呼],销售前期,销售中期,员工仪容仪表,整体感受,平均分 FROM ##Elearning2 group by TopicID,Code,连带销售,试衣室服务,售后服务,[问候/招呼],销售前期,销售中期,员工仪容仪表,整体感受,平均分rnSET @errorSun=@errorSun+@@ERROR --累计是否有错rnUPDATE Elearning_AnswerSheet_Topic SET TopicName=(select Name from Elearning_Topics where Elearning_AnswerSheet_Topic.TopicID=Elearning_Topics.TopicID)rnSET @errorSun=@errorSun+@@ERROR --累计是否有错rnendrnendrnrnIF @errorSun<>0rnBEGINrnROLLBACK TRANSACTION--事务回滚语句rnENDrnELSErnBEGINrnCOMMIT TRANSACTION--事务提交语句rnENDrn[/code]rnrn提示出错信息如下:rn')' 附近有语法错误。rn'n' 附近有语法错误。rn对象名 '##Elearning2' 无效。rnEXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配。上一计数 = 0,当前计数 = 1。 rn说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 rnrn异常详细信息: System.Data.SqlClient.SqlException: ')' 附近有语法错误。rn'n' 附近有语法错误。rn对象名 '##Elearning2' 无效。rnEXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配。上一计数 = 0,当前计数 = 1。rnrn
EXECUTE 后的事务计数指出缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。原计数 = 0,当前计数 = 1。
EXECUTE 后的事务计数指出缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。原计数 = 0,当前计数 = 1。rn存储过程: MediaFeeder.dbo.momo_forvod_sound_sprn 返回代码 = 0rn
EXECUTE 后的事务计数指出缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。原计数 = 0,当前计数 = 1
下面的存储过程哪儿有问题:rn望大虾们指点.rn CREATE PROCEDURE dbo.spOrdersInsertrn(rn @CustomerID INT,rn @CartID VARCHAR(50),rn @Memo VARCHAR(2000),rn @OrderID INT OUTPUTrn)rnASrnrn-- 确保数据的一致性, 因而起用事务rnBEGIN TRAN OrdersInsertrnrn/* 产生订单 */rnINSERT INTO Ordersrn(rn CustomerID,rn Memorn)rnVALUESrn(rn @CustomerID,rn @Memorn)rnrn-- 返回当前所产生的OrderIDrnSELECTrn @OrderID = @@Identity rnrn/* 将当前用户的当前购物车COPY到当前所产生的ORDER明细中*/rnINSERT INTO OrderDetailsrn(rn OrderID, rn ProductID, rn Quantity, rn UnitCostrn)rnrnSELECT rn @OrderID, rn ShoppingCart.ProductID, rn Quantity, rn Products.UnitCostrnrnFROM rn ShoppingCart rn INNER JOIN Products ON ShoppingCart.ProductID = Products.ProductIDrn rnWHERE rn CartID = @CartIDrnrn/* 完成后, 清空当前购物车ID的所有明细*/rnEXEC spShoppingCartEmpty @CartIdrnrnCOMMIT TRAN OrdersInsertrnGOrn
如何解决---???--EXECUTE 后的事务计数指出缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。原计数 = 0,当前计数 = 1
我的存储过程中使用了BEGIN TRANSACTION T1语句,rnrn只后有使用exec调用其它程序过程,其它存储过程中没有相关事务的语句rnrn结果发生了这个错误,请问改如何解决呢?
EXECUTE 后的事务计数指出缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。原计数 = 0,当前计数 = 1???
我的存储过程是这样的,请问哪里有问题??rnCREATE procedure Up_TaoKouReturn_Add rn@returnnum numeric(18,2),--返料数量rn@returntime datetime, --返料时间 rn@remark varchar(500), --备注 rn@getid int --领料IDrnrnrnasrndeclare @returnsumnum numeric(18,2) --已经收货的总数量 rndeclare @getnum int --发货数量 rnbegin tran rnselect @returnsumnum=returnsumnum,@getnum=getnum from tbtaokouget where getid=@getid rnrnrninsert into tbTaoKouReturn(returnnum,returntime,remark,getid) values(@returnnum,@returntime,@remark,@getid)rnif ((@returnsumnum+@returnnum)=@getnum) --已完成 rnrnbeginrnupdate tbtaokouget set returnsumnum =returnsumnum+@returnnum,status=3,returnLastTime=@returntime where getid=@getidrnend rnrnelse if ((@returnsumnum+@returnnum)<@getnum) --未完成 rnbegin rnupdate tbtaokouget set returnsumnum =returnsumnum+@returnnum,status=2,returnLastTime=@returntime where getid=@getidrnrnend rnrnelsernrnreturn 0rnrnrnrnif @@error=0 rncommit tran rnelsernrollback tranrnGOrn
execute后的事务计数指出缺少了commit或rollback transaction 语句。原计数=0,当前计数=1
execute后的事务计数指出缺少了commit或rollback transaction 语句。原计数=0,当前计数=1,请问这是什么错误 啊,下面是我写的存储过程,请大家帮帮忙。rnrnALTER PROCEDURE dbo.alterSFQDrn(rn @id int,rn @bid char(10),rn @jb int,rn @rq datetime = null,rn @szdd varchar(50) = null,rn @dwid int,rn @hkid int,rn @sycjs decimal = null,rn @bycjs decimal,rn @ysl decimal = null,rn @dj money,rn @je money = null,rn @sfhb char(4) = null,rn @sfyfb char(4),rn @bz ntext = null,rn @maxvalue decimal = null,rn @result varchar(50) output,rn @count int = nullrn)rnASrn set @rq = getdate()rn if @sycjs < @bycjsrn begin rn set @ysl = @bycjs - @sycjsrn set @je = @ysl * @djrn set @sfhb = '否'rn endrn elsern beginrn set @maxvalue = (select MaxValue from waterbiao where bid = @bid)rn set @ysl = @maxvalue - @sycjs + @bycjsrn set @je = @ysl * @dj rn set @sfhb = '是'rn endrn begin transactionrn update sfqdrn set bid=@bid, rq = @rq,szdd = @szdd,dwid = @dwid,hkid = @hkid,bycjs = @bycjs,ysl = @ysl,dj = @dj,je = @je,sfhb = @sfhb,sfyfb = @sfyfb,bz = @bzrn where id = @idrn rn set @count = (select count(id) from sfqd where bid=@bid and year(rq)=year(getdate()) and month(rq)=month(getdate()))rn if @count > 1rn begin rn rollback tranrn set @result = '此表卡号已录入,更新错误'rn endrn elsern beginrn set @result = '该记录已更新'rn returnrn endrn commit transactionrn
"EXECUTE 后的事务计数指出缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。原计数 = 0,当前计数 = 1。"
我在一个存储过程以前测试好好的,今天加上事务后,检查语法也通过了,但执行时总是提示“EXECUTE 后的事务计数指出缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。原计数 = 0,当前计数 = 1。”rn存储过程如下:rnCREATE PROCEDURE [update_kc_minus_rktd]rn @djh intrnASrnBeginrnSET XACT_ABORT on --有错误回滚rnbegin transaction rktd --事务开始rnrnif (select quit from rkd where rkdjh=@djh)=1rnRETURN 1rnif exists(select 1 from kc inner join rkdxm on kc.ypID=rkdxm.ypID and kc.rkdj=rkdxm.rkdj where rkdxm.rkdjh=@djh and kc.kcsl
消息 266,级别 16,状态 2,过程 UserExchange,第 0 行 EXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配。上一计数 = 0,当前计数 = 1。
BEGIN TRAN IF ( NOT EXISTS ( SELECT * FROM dbo.Exchanged WHERE LevelID = @LevelID ) ) BEGIN SELECT @PaketID = Adv
【这个错误怎么办?】EXECUTE 后的事务计数指示缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。上一计数 = 1,当前计数 = 2
我的写了sql存储过程,出现这个错误,是怎么回事?麻烦大神给可能下!本人先谢了!rn这个是报错的那段代码,应该怎么改呢?rn[code=sql]rnnextinsert: rn--插入月结主表对应数据 rninsert into dbo.t_StockStoragern ( c_ID ,rn c_Type ,rn c_JigouID ,rn c_Month ,rn c_StaffID ,rn c_Ctime ,rn c_Remarkrn )rnVALUES ( @storid, -- c_ID - nvarchar(50)rn '无毛绒' , -- c_Type - nvarchar(50)rn @JigouID , -- c_JigouID - nvarchar(50)rn @yjtime, -- c_Month - datetimern @staffid , -- c_StaffID - nvarchar(50)rn @createtime , -- c_Ctime - datetimern @remark -- c_Remark - ntextrn )rn--获取插入到月结主表最新的主键id rnselect @storageId = scope_identity() rn rn/*计算库存月结数据逻辑SQL语句,可以利用临时表或with cte的用法,下文以cte为主。*/ rn rn--向月结子表插入数据 rn--insert into StockStorageDetail rn--select @storageId,productid,quantity rn--from cte rnrnrnIF EXISTS(SELECT 1 FROM dbo.t_StockStorage WHERE c_JigouID=@JigouID)rn /*第一种情况:从未做过月结*/rnBEGINrnSELECT * INTO #t_inv FROM dbo.t_CashmereInventory WHERE c_Pihao IN (SELECT c_Pihao FROM dbo.v_CashmereInBodyDetails WHERE c_time<=@yjtime AND c_jigouID=@JigouID AND IsAccount=1)rnUPDATE #t_inv SET c_Inventory=0 --将数据归零准备重新计算rnDECLARE yb_ph CURSOR FOR rn SELECT c_Pihao,c_ChangduID,c_PositionID FROM #t_inv WHERE c_JiGouID=@JigouID;rnSELECT @count = count(*) FROM #t_inv WHERE c_JiGouID=@jigouid;rnOPEN yb_phrnWHILE @count >0 AND @@FETCH_STATUS=0rn rn BEGINrn FETCH NEXT FROM yb_ph INTO @pihao,@changdu,@kuweirn /*先取入库数据进行运算*/rn SELECT @rksj =c_Weight FROM dbo.v_CashmereInBodyDetails WHERE c_Pihao=@pihao AND LengthID=@changdu AND c_PositionID=@kuwei AND c_jigouID=@JigouIDrn UPDATE #t_inv SET c_Inventory=c_Inventory+@rksj WHERE c_Pihao=@pihao AND c_ChangduID=@changdu AND c_PositionID=@kuwei AND c_jigouID=@JigouID rn /*再取出库数据进行运算*/rn SELECT @cksj =c_Weight FROM dbo.v_CashmereOutDetails WHERE c_Pihao=@pihao AND LenthID=@changdu AND c_PositionID=@kuwei AND c_jigouID=@JigouIDrn UPDATE #t_inv SET c_Inventory=c_Inventory-@cksj WHERE c_Pihao=@pihao AND c_ChangduID=@changdu AND c_PositionID=@kuwei AND c_jigouID=@JigouIDrn /*将数据插入到月结明细表中*/rn INSERT INTO dbo.t_StockStorageDetailrn ( c_StorageId ,rn c_Pihao ,rn c_Pinming ,rn c_ChangduID ,rn c_Inventory ,rn c_Remark ,rn c_PositionID ,rn c_JiGouID ,rn c_Bianma ,rn c_Xidu ,rn c_Hancu ,rn c_Yise ,rn c_PType ,rn c_Chundu ,rn c_Yizhi ,rn c_Fupi ,rn c_Duanrongrn )rn SELECT @storid,rn c_Pihao ,rn c_Pinming ,rn c_ChangduID ,rn c_Inventory ,rn c_Remark ,rn c_PositionID ,rn c_JiGouID ,rn c_Bianma ,rn c_Xidu ,rn c_Hancu ,rn c_Yise ,rn c_PType ,rn c_Chundu ,rn c_Yizhi ,rn c_Fupi ,rn c_Duanrongrn FROM #t_invrn ENDrnrnENDrnELSErn/*已经有月结记录,本期库存=期初库存+入库-出库*/rnSELECT * INTO #t_inv0 FROM dbo.t_CashmereInventory WHERE 1>1rn--从月结表中先将上月期初数据复制过来rnINSERT INTO #t_inv0rn ( c_Pihao ,rn c_Pinming ,rn c_ChangduID ,rn c_Inventory ,rn c_Remark ,rn c_PositionID ,rn c_JiGouID ,rn c_Bianma ,rn c_Xidu ,rn c_Hancu ,rn c_Yise ,rn c_PType ,rn c_Chundu ,rn c_Yizhi ,rn c_Fupi ,rn c_Duanrongrn )rn SELECT rn c_Pihao ,rn c_Pinming ,rn c_ChangduID ,rn c_Inventory ,rn c_Remark ,rn c_PositionID ,rn c_JiGouID ,rn c_Bianma ,rn c_Xidu ,rn c_Hancu ,rn c_Yise ,rn c_PType ,rn c_Chundu ,rn c_Yizhi ,rn c_Fupi ,rn c_Duanrong rn FROM dbo.t_StockStorageDetail WHERE c_StorageId IN(SELECT c_ID FROM dbo.t_StockStorage WHERE c_Month=DATEADD(MONTH,-1,@yjtime) AND c_JigouID=@JigouID) rn rn /*从库存表中复制上月新增批号的数据*/rn DECLARE @yjPrev DATETIME ---上一个月结时间rn DECLARE @InvID VARCHAR(50) --保存库存IDrn DECLARE @pihao_n VARCHAR(50) --保存游标批号rn DECLARE @changdu_n VARCHAR(50) --保存游标长度rn DECLARE @kuwei_n VARCHAR(50) --保存游标库位rn rn rn SELECT @yjPrev=c_Month FROM dbo.t_StockStorage WHERE c_Month=DATEADD(MONTH,-1,@yjtime) AND c_JigouID=@JigouIDrn rn DECLARE yb_phmuti CURSOR FOR rn SELECT c_Pihao,LengthID,c_PositionID FROM dbo.v_CashmereInBodyDetails WHERE c_jigouID=@jigouid AND c_time<=@yjtime AND c_time>=@yjPrev AND c_jigouID=@JigouID AND IsAccount=1 ;rn SELECT @count = count(*) FROM #t_inv0 WHERE c_JiGouID=@JigouID AND c_time<=@yjtime AND c_time>=@yjPrev AND c_jigouID=@JigouID AND IsAccount=1;rn rn OPEN yb_phmuti;rn WHILE @count > 0 AND @@FETCH_STATUS=0rn /*存储游标循环*/rn BEGINrn FETCH NEXT FROM yb_phmuti INTO @pihao_n,@changdu_n,@kuwei_n;rn IF NOT EXISTS(SELECT 1 FROM #t_inv0 WHERE c_Pihao=@pihao_n AND c_ChangduID=@changdu_n AND c_PositionID=@kuwei_n)rn INSERT INTO #t_inv0rn ( c_Pihao ,rn c_Pinming ,rn c_ChangduID ,rn c_Inventory ,rn c_Remark ,rn c_PositionID ,rn c_JiGouID ,rn c_Bianma ,rn c_Xidu ,rn c_Hancu ,rn c_Yise ,rn c_PType ,rn c_Chundu ,rn c_Yizhi ,rn c_Fupi ,rn c_Duanrongrn )rn SELECT rn c_Pihao ,rn c_Pinming ,rn c_ChangduID ,rn 0 , --默认为0rn c_Remark ,rn c_PositionID ,rn c_JiGouID ,rn c_Bianma ,rn c_Xidu ,rn c_Hancu ,rn c_Yise ,rn c_PType ,rn c_Chundu ,rn c_Yizhi ,rn c_Fupi ,rn c_Duanrongrn FROM dbo.t_CashmereInventory WHERE c_Pihao=@pihao_n AND c_PositionID=@kuwei_n AND c_ChangduID=@changdu_n AND c_JiGouID=@JigouID rn END rn /*循环结束*/rn /*开始计算*/rn DECLARE yb_phjs CURSOR FOR rn SELECT c_Pihao,c_ChangduID,c_PositionID FROM #t_inv0;rn SELECT @count = count(*) FROM #t_inv0;rn OPEN yb_phjsrn WHILE @count >0 AND @@FETCH_STATUS=0rn BEGINrn FETCH NEXT FROM yb_phjs INTO @pihao,@changdu,@kuwei;rn --计算入库数据rn SELECT @rksj =c_Weight FROM dbo.v_CashmereInBodyDetails WHERE c_Pihao=@pihao AND LengthID=@changdu AND c_PositionID=@kuwei AND c_jigouID=@JigouIDrn UPDATE #t_inv0 SET c_Inventory=c_Inventory+@rksj WHERE c_Pihao=@pihao AND c_ChangduID=@changdu AND c_PositionID=@kuwei AND c_jigouID=@JigouID rn --计算出库数据rn SELECT @cksj =c_Weight FROM dbo.v_CashmereOutDetails WHERE c_Pihao=@pihao AND LenthID=@changdu AND c_PositionID=@kuwei AND c_jigouID=@JigouIDrn UPDATE #t_inv0 SET c_Inventory=c_Inventory-@cksj WHERE c_Pihao=@pihao AND c_ChangduID=@changdu AND c_PositionID=@kuwei AND c_jigouID=@JigouIDrn /*将数据插入到月结明细表中*/rn INSERT INTO dbo.t_StockStorageDetailrn ( c_StorageId ,rn c_Pihao ,rn c_Pinming ,rn c_ChangduID ,rn c_Inventory ,rn c_Remark ,rn c_PositionID ,rn c_JiGouID ,rn c_Bianma ,rn c_Xidu ,rn c_Hancu ,rn c_Yise ,rn c_PType ,rn c_Chundu ,rn c_Yizhi ,rn c_Fupi ,rn c_Duanrongrn )rn SELECT @storid,rn c_Pihao ,rn c_Pinming ,rn c_ChangduID ,rn c_Inventory ,rn c_Remark ,rn c_PositionID ,rn c_JiGouID ,rn c_Bianma ,rn c_Xidu ,rn c_Hancu ,rn c_Yise ,rn c_PType ,rn c_Chundu ,rn c_Yizhi ,rn c_Fupi ,rn c_Duanrongrn FROM #t_inv0rn endrnif(@@error<>0) goto Failure rncommit transaction rnset @text = @warehousename+replace(convert(varchar(7),@yjtime,120),'-','年')+'月月结数据插入已完成!' rnreturnrn[/code]rn
execute 后的事务计数支出缺少了 commit 或 rollback transaction 语句。原计数=1,当前计数=0。
我在查询分析器中执行语句“ exec dccgc '' ”会提示rn“EXECUTE 后的事务计数指出缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。原计数 = 1,当前计数 = 0。”,但是在delphi中用ado执行“ exec dccgc '' ”并不报错,执行后数据库中的数据还是对的,是不是这个提示对存储过程的执行没有影响可以忽略,但是我的存储过程到底哪里写的不对呢???存储过程如下:rnrn小存储过程rn/*********************************************************************************rnif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[xccgc]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)rndrop procedure [dbo].[xccgc]rnGOrnrnSET QUOTED_IDENTIFIER ON rnGOrnSET ANSI_NULLS ON rnGOrnrnrnCREATE PROCEDURE xccgcrn@outmsg varchar(200) outputrnrnASrndeclare @i intrnSet xact_abort on rnBEGIN TRANSACTION rn update a set a='aaa'rn where id=1rn set @i=@@rowcountrn if @i=1 ----此处造成回滚rn beginrn set @outmsg='小存储过程回滚'rn rollback rn returnrn endrn if @@error<>0 rn beginrn set @outmsg='小存储过程回滚'rn rollback rn returnrn endrnrnrnCOMMIT TRANSACTION rnset @outmsg='小存储过程成功'rnreturnrnSet xact_abort off rnrnrnrnGOrnSET QUOTED_IDENTIFIER OFF rnGOrnSET ANSI_NULLS ON rnGOrnrnrn*********************************************************************************/rnrnrnrnrnrn大存储过程rnrn/*********************************************************************************rnif exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[dccgc]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)rndrop procedure [dbo].[dccgc]rnGOrnrnSET QUOTED_IDENTIFIER ON rnGOrnSET ANSI_NULLS ON rnGOrnrnrnCREATE PROCEDURE dccgcrn@outmsg varchar(200) outputrnrnASrnSet xact_abort onrnBEGIN TRANSACTION rn declare @outmsg1 varchar(200)rn exec xccgc @outmsg1 outputrn if @outmsg1='小存储过程回滚'rn beginrn set @outmsg=@outmsg+'由于小存储过程回滚导致大存储过程回滚'rn print @outmsgrn rollback rn returnrn endrn update b set b='bbb'rn if @@error<>0 rn beginrn set @outmsg=@outmsg+'大存储过程自身回滚'rn print @outmsgrn rollback rn returnrn endrnrncommit TRANSACTION rnset @outmsg='大存储过程成功'rnprint @outmsgrnrnreturnrnSet xact_abort offrn*********************************************************************************/
在线问题:rollback怎么用?execute后的事务缺少commit或rollback transation语句,原计数=1,当前计数=0
/*产生住院就诊号*/rnCREATE PROCEDURE dp_zyjzdj @li_ddbh int,@ls_ylh varchar(20),@ls_cybm varchar(20),@ls_czyxm varchar(20),@ldt_cysj datetime, @ls_jzh varchar(13) outputrnASrnBEGINrn rn declare @ls_tjzh varchar(13)rn declare @li_row intrn declare @ls_xm varchar(20)rn declare @ls_xb varchar(20)rn declare @ls_sfz varchar(25)rn declare @ls_jtdz varchar(100)rn declare @ldt_csrq datetimern select @ls_xm=xm,@ls_xb=xb,@ldt_csrq=csrq,@ls_sfz=sfz,@ls_jtdz=jtdzrn from v_cbryzl_cyrn where cybm=@ls_cybmrn select @li_row=@@rowcountrn if @@error<>0rn beginrn Select @ls_jzh='-1'/*查询参保人员资料错误*/rn returnrn endrn if @li_row=0rn beginrn select @ls_jzh='-2'/*查询不到此医疗证号*/rn returnrn endrn rn select @ls_tjzh=isnull(max(jzh),'0')rn from zyjzdjrn where ddbh=@li_ddbhrnrn select @li_row=@@ROWCOUNTrn if @@error<>0rn beginrn select @ls_jzh='-3'/*查询就诊号错误*/rn returnrn endrn rn if @li_row = 1rn beginrn select @ls_jzh=cast(cast(@ls_tjzh as decimal(13,0))+1 as varchar(13))rn endrn BEGIN TRANSACTIONrn insert into zyjzdj (ddbh,jzh,ylh,cybm,xm,xb,csrq,sfz,dz,rysj,cysj,czyxm,srsj)rn values (@li_ddbh,@ls_jzh,@ls_ylh,@ls_cybm,@ls_xm,@ls_xb,@ldt_csrq,@ls_sfz,@ls_jtdz,getdate(),@ldt_cysj,@ls_czyxm,getdate())rn if @@error<>0rn beginrn select @ls_jzh='-4'/*插入就诊信息失败*/rn rollback transactionrn returnrn endrn commit transactionrnEND
给存储过程加入事务后,程序出错提示EXECUTE 后的事务计数指出缺少了 COMMIT或 ROLLBACK TRANSACTION 语句。原计数 = 0,当前计数 = 1。
给存储过程加入事务后,程序出错提示EXECUTE 后的事务计数指出缺少了 COMMIT或 ROLLBACK TRANSACTION 语句。原计数 = 0,当前计数 = 1。 rn不知道是什么原因:rnrnbegin tranrnrn…………rnrncommit tranrn会有什么错呢?rn
▲▲▲System.Data.SqlClient.SqlExceptionEXECUTE 后的事务计数指出缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。原计数 = 0,当前计数
我的存贮过程为什么有的时候执行正确,有的时候报这个错误呀??
参数计数不匹配?
Dim parts() As String = _callbackEventArgument.Split("|")rn Dim result As String = ""rn Dim args() As Object = Nothingrn If parts.Length > 1 Thenrn ReDim args(parts.Length - 2)rn Array.Copy(parts, 1, args, 0, args.Length)rn End Ifrnrn Dim method As MethodInfo = Me.GetType().GetMethod(parts(0))rn If Not method Is Nothing Thenrn result = method.Invoke(Me, args)rnrn End Ifrn Return resultrn执行到result = method.Invoke(Me, args)时,出错提示"参数计数不匹配"rn如果callbackEventArgument="FillProduct|aaa"则正确,rn如果callbackEventArgument="FillProduct|aaa|bbb"会出现以上的错误信息.rn
参数计数不匹配
public delegate void UpdateListView(string [] request);//委托函数声明rnrnstring[] request = receive.Split('@');rnUpdateListView UpdateLV=new UpdateListView (UpdateListview);rnthis.Invoke(UpdateLV, request);//这里报错rnrnrnvoid UpdateListview(string[] request)rnrn int i = 0;rn ListViewItem lvi;rn ListViewItem.ListViewSubItem lvsi;rn while (request[i]!="")rn rn lvi = new ListViewItem();rn lvi.Text = request [i ];rnrn lvsi = new ListViewItem.ListViewSubItem();rn lvi.Text = request [i+1];rn i += 2;rnrn rn rn为什么会报参数计数不匹配的错的呢?
BEGIN 和 COMMIT 语句的数目不匹配
EXECUTE 后的事务计数指示 BEGIN 和 COMMIT 语句的数目不匹配。上一计数 = 1,当前计数 = 2。老是出现这样的问题,怎么彻底解决呀
计数,计数,计数!!!求教!!!
各位前辈,小弟想实现的是如何记下一个页面的访问次数???rnrn在线等,急,多谢!!!!!!!!!!!!!!!
错误提示 :EXECUTE 后的事务计数指示缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句
[code=SQL]CREATE PROCEDURE pr_getjyh @in_pzh char(10),@in_gysh char(6) , @rval integer OUTPUT rnASrnDECLARE @rq datetimernDECLARE @spbh char(10)rnDECLARE @gysh char(6)rnDECLARE @ggxh char(40)rnDECLARE @weight decimal(5, 2)rnDECLARE @Code char(30)rnDECLARE @spmc char(30)rnrnDECLARE csr_getjyh CURSOR FOR SELECT rq,spbh,spmc,gysh, ggxh1, weight FROM f_jdtzd where pzh=@in_pzh Order by spbhrnselect @rval = -1 rnbegin transaction tran_jyhshrnopen csr_getjyhrnfetch next from csr_getjyh into @rq, @spbh,@spmc,@gysh,@ggxh,@weightrnwhile (@@fetch_status<>-1)rnbeginrn Select TOP 1 @Code =Code From Temp_HJJYH Where bz='0' order by idrn IF @@ERROR<>0rn beginrn rollback transaction tran_jyhshrn close csr_getjyhrn deallocate csr_getjyhrn print '检验号已用完'rn select @rval = -10rn returnrn endrnrn if not exists(select 1 from HJJYH where Code=@Code) rn beginrn Insert into HJJYH( Spbh, Code, GoldName, Number, Weight) values(@spbh,@Code,@spmc,@ggxh,@weight)rn IF @@ERROR<>0rn beginrn rollback transaction tran_jyhshrn close csr_getjyhrn deallocate csr_getjyhrn print @Code + '插入HJJYH表失败'rn select @rval = -12rn returnrn endrnrn update Temp_HJJYH Set bz='1' where Code=@Codern IF @@ERROR<>0rn beginrn rollback transaction tran_jyhshrn close csr_getjyhrn deallocate csr_getjyhrn print @Code + '更新Temp_HJJYH已使用标记失败'rn select @rval = -12rn returnrn endrn endrn elsern beginrn rollback transaction tran_jyhshrn close csr_getjyhrn deallocate csr_getjyhrn print '此检验号已使用'+@Codern select @rval = -11rn returnrn endrnfetch next from csr_getjyh into @rq, @spbh,@spmc,@gysh,@ggxh,@weightrnendrnrnrncommit transaction tran_jyhshrnclose csr_getjyhrndeallocate csr_getjyhrnselect @rval=0rnGO[/code]rnrn没有细化的学习过,请专业人士帮忙查看下我这存储过程有哪些问题,请指出并给予正确的写法,万分感谢!
EXECUTE 后的事务计数指示缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句
[code=SQL]rnBEGIN TRANSACTION;rnBEGIN TRYrn --代码太长省略 rnEND TRYrnBEGIN CATCHrn SELECT ERROR_MESSAGE() as ErrorMessage;rn IF @@TRANCOUNT > 0rn ROLLBACK TRANSACTION;rnEND CATCH;rnIF @@TRANCOUNT > 0rn COMMIT TRANSACTION;rn-----报错rn消息 266,级别 16,状态 2,过程 sp_sys_flowlogic,第 187 行rnEXECUTE 后的事务计数指示缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。上一计数 = 0,当前计数 = 1。rnrn[/code]rnrn有个脚本执行有错,提示在第 187 行,187行前后删除依然报错,还没找不到具体哪行问题。很奇怪为什么事物的提交或回滚并没有执行,导致锁了进程,难道写法有问题?。rn这个过程使用率很高,报错这个时间段用户一直在执行,临时的解决办法写个监控kill掉锁死进程。 rnrn各位大神,求更好的解决办法,这个错误为啥捕获不到呢?在线等rn
this.Invoke参数计数不匹配
多线程中经常会需要需更新主线程中的UI。 以前传参时,委托参数表都是(string str,int num)这样的,然后在this.invoke传第二个参数时这样:new objects[]{"test",123}。 结果今天脑残了,委托的参数写成:(object[] objs),看上去挺对的啊,跟invoke传参时候长得一模一样,噗。然后就抛出了“参数计数不匹配”这样的异常。 解决
execute后的事务计数指示缺少了commit或rollback transaction
发些前台代码 SqlConnection con = baseoperate.getcon();rn con.Open();rn SqlTransaction tran = con.BeginTransaction();rn tryrn rn foreach (DataGridViewRow row in dataGridView1.Rows)rn rn SqlCommand sqlcom = new SqlCommand("GoodsOutput", con);rn sqlcom.Transaction = tran;rn sqlcom.CommandType = CommandType.StoredProcedure;rn sqlcom.Parameters.AddWithValue("@出仓单号", MOdanhao.Text);rn sqlcom.Parameters.AddWithValue("@出仓日期", MOdate.Value);rn sqlcom.Parameters.AddWithValue("@操作人员代码", MOperson.Text);rn sqlcom.Parameters.AddWithValue("@物料代码", Convert.ToString(row.Cells[0].Value));rn sqlcom.Parameters.AddWithValue("@数量", Convert.ToInt32(row.Cells[1].Value));rn sqlcom.Parameters.AddWithValue("@备注", MOremark.Text);rn sqlcom.Parameters.Add(new SqlParameter("@return",SqlDbType.Int));rn sqlcom.Parameters["@return"].Direction=ParameterDirection.ReturnValue;rn sqlcom.ExecuteNonQuery(); rn if (int.Parse(sqlcom.Parameters["@return"].Value.ToString())==0)rn rn tran.Rollback();rn MessageBox.Show("数量不足");rn return;rn rn sqlcom.Dispose();rnrnrnrnrnrnGoodsOutput存储过程rnrnset ANSI_NULLS ONrnset QUOTED_IDENTIFIER ONrnGOrnALTER procedure [dbo].[GoodsOutput] @出仓单号 nchar(20),@出仓日期 datetime,@操作人员代码 nchar(10),rn @物料代码 nchar(16),@数量 int,@备注 nchar(20)rnASrnbegin transactionrndeclare @序号 int,@number intrnif not exists(select * from Output)rn set @序号=1rnelsern set @序号=(select max(序号) from Output)+1rnset @number=(select 库存量 from material where 物料代码=@物料代码)-@数量rnif @number<0 rn beginrn rollbackrn return 0rn endrnelsern beginrn insert into Output values(@序号,@出仓单号,@出仓日期,@操作人员代码,@备注,@物料代码,@数量)rn update material set 库存量=库存量-@数量 where 物料代码=@物料代码rn commitrn return 1rn end rnrn rnrnrnrn把存储过程的事务去掉就不会出错,添加上去就出错。 求个解决方法 (不能取消事务) rn
EXECUTE后的事务指数指出缺少了commit或rollback TRANSACTION语句,原计数=1,当前计=0
各位上面所说是什么问题啊存储过程为:rnrn/*产生住院就诊号*/rnCREATE PROCEDURE dp_zyjzdj @li_ddbh int,@ls_ylh varchar(20),@ls_cybm varchar(20),@ls_czyxm varchar(20),@ldt_cysj datetime, @ls_jzh varchar(13) outputrnASrnBEGINrn declare @ls_tjzh varchar(13)rn declare @li_row intrn declare @ls_xm varchar(20)rn declare @ls_xb varchar(20)rn declare @ls_sfz varchar(25)rn declare @ls_jtdz varchar(100)rn declare @ldt_csrq datetimern select @ls_xm=xm,@ls_xb=xb,@ldt_csrq=csrq,@ls_sfz=sfz,@ls_jtdz=jtdzrn from v_cbryzl_cyrn where cybm=@ls_cybmrn select @li_row=@@rowcountrn if @@error<>0rn beginrn Select @ls_jzh='-1'/*查询参保人员资料错误*/rn returnrn endrn if @li_row=0rn beginrn select @ls_jzh='-2'/*查询不到此医疗证号*/rn returnrn endrnrn select @ls_tjzh=isnull(max(jzh),'0')rn from zyjzdjrn where ddbh=@li_ddbhrnrn select @li_row=@@ROWCOUNTrn if @@error<>0rn beginrn select @ls_jzh='-3'/*查询就诊号错误*/rn returnrn endrnrn if @li_row = 1rn beginrn select @ls_jzh=cast(cast(@ls_tjzh as decimal(13,0))+1 as varchar(13))rn endrn /* select @@trancount*/rn BEGIN TRANSACTIONrn insert into zyjzdj (ddbh,jzh,ylh,cybm,xm,xb,csrq,sfz,dz,rysj,cysj,czyxm,srsj)rn values (@li_ddbh,@ls_jzh,@ls_ylh,@ls_cybm,@ls_xm,@ls_xb,@ldt_csrq,@ls_sfz,@ls_jtdz,getdate(),@ldt_cysj,@ls_czyxm,getdate())rn if @@error<>0rn beginrn select @ls_jzh='-4'/*插入就诊信息失败*/rn rollback transactionrn select @@trancountrn returnrn endrn commit TRANSACTIONrn select @@trancountrn returnrnEND
计数
#include int main() {     int num;     scanf ("%d", &num);     int a[10] = {0};     int i;     int temp;     for (i = 0; i     {         if (i == 0)         {             a[i]+
count(*)计数后显示0
[img=https://img-bbs.csdn.net/upload/201712/19/1513651491_976985.jpg][/img]
相关热词 c#入门推荐书 c# 解码海康数据流 c# xml的遍历循环 c# 取 查看源码没有的 c#解决高并发 委托 c#日期转化为字符串 c# 显示问号 c# 字典对象池 c#5.0 安装程序 c# 分页算法