EXECUTE 后的事务计数指出缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句

male110 2009-02-24 10:41:00
ALTER PROCEDURE [dbo].[Proc_DomainSales_Pay]
@id int,--域名拍卖表ID
@uid int,--用户ID
@money numeric(18, 2),--冻结金额
@ret int output --成功返回1,失败返回零
AS
BEGIN
begin transaction
if(@money>0)
begin
--解冻拍卖领先金额-Start
declare @congeal_moneysum numeric(9,2)
set @congeal_moneysum = 0
select @congeal_moneysum = moneysum FROM eb_congeal where userid=@uid and linkid=@id and types = 2 and state = 1
if not @congeal_moneysum is null and @congeal_moneysum <> 0
begin
-- 更新用户冻结金额
update eb_user set usemoney=usemoney + @congeal_moneysum, Congealsum = Congealsum - @congeal_moneysum where id = @uid
if(@@error<>0)
begin
set @ret=0;
rollback transaction;
return 1;
end
update eb_congeal set state= 0 where userid=@uid and linkid=@id and types = 1 and state = 1
if(@@error<>0)
begin
set @ret=0;
rollback transaction;
return 1;
end
end

--解冻拍卖领先金额--End

declare @strdomain varchar(256);
--修改用户可用金额
update eb_user set useMoney=useMoney-@money, Congealsum=Congealsum+@money where id=@uid
if(@@error<>0)
begin
set @ret=0;
rollback transaction;
return 1;
end
select @strdomain=strdomain from EB_domain_sals where userid=@uid
--增加冻结信息
INSERT INTO EB_Congeal( [linkid], [Moneysum], [userid], [types], [remark], [addtime], [state])
VALUES(@id,@money,@uid,102,'支付拍卖域名'+@strdomain+'冻结',getdate(),1);
if(@@error<>0)
begin
set @ret=0;
rollback transaction;
return 1;
end
--增加财务记录
--改变域名操作状态
update Eb_domain_sals set mkstate=1 where[id]=@id
end

if(@@error =0)
begin
set @ret=1
commit transaction;
return 1;
end

set @ret=0
rollback transaction

END

程序在执行时,提示
EXECUTE 后的事务计数指出缺少了 COMMIT 或 ROLLBACK TRANSACTION 语句。原计数 = 0,当前计数 = 1
我实在看不出来哪儿的问题
...全文
108 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
male110 2009-02-24
  • 打赏
  • 举报
回复
if(@@error =0)
begin
set @ret=1
commit transaction;
return 1;
end

set @ret=0
rollback transaction
有提交回滚呀?

在这个提交回滚之前也没有return
  • 打赏
  • 举报
回复
事务没用提交或者回滚?

34,588

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧