单步存储过程的几个问题

bigbigcai bigbigcai 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
我的存储过程:

CREATE PROCEDURE Test @ID nvarchar(12),@AddMoney money
AS
DECLARE @_money money
DECLARE @_欠款金额 money
DECLARE @_Temp money


SELECT

@_money=Money.dbo._Main._money, @_欠款金额=NM2000.dbo.l_reader._欠款金额
from
Money.dbo._Main,NM2000.dbo.l_reader

where

Money.dbo._Main._id=@ID and NM2000.dbo.l_reader._读者条码=@ID

if(@_欠款金额=0 or @_欠款金额>0 and @_money>=20 )

begin
set @_money=@AddMoney+@_money
update Money.dbo._Main set Money.dbo._Main._money=@_money where Money.dbo._Main._id=@ID
end

if(@_欠款金额>0 and @_money<20)
begin

if (@Addmoney+@_money<20)
begin
set @_money=@AddMoney+@_money
set @_欠款金额=@_欠款金额-@AddMoney
update Money.dbo._Main set Money.dbo._Main._money=@_money where Money.dbo._Main._id=@ID
update NM2000.dbo.l_reader set NM2000.dbo.l_reader._欠款金额=@_欠款金额 where NM2000.dbo.l_reader._读者条码=@ID
end

if (@Addmoney+@_money>=20)
begin
set @_Temp=20-@_money
set @_money=@AddMoney+@_money
set @_欠款金额=@_欠款金额-@_Temp
update Money.dbo._Main set Money.dbo._Main._money=@_money where Money.dbo._Main._id=@ID
update NM2000.dbo.l_reader set NM2000.dbo.l_reader._欠款金额=@_欠款金额 where NM2000.dbo.l_reader._读者条码=@ID
end

end
GO

单步的时候一到set就报:

ODBC: 消息 0,级别 19,状态 1
[Microsoft][ODBC SQL Server Driver][SQL Server]SqlDumpExceptionHandler: 进程 58 发生了严重的异常 c0000005 EXCEPTION_ACCESS_VIOLATION。SQL Server 将终止该进程。


[Microsoft][ODBC SQL Server Driver][Shared Memory]ConnectionRead (WrapperRead()).


服务器: 消息 11,级别 16,状态 1,行 0
[Microsoft][ODBC SQL Server Driver][Shared Memory]一般性网络错误。请检查网络文档。


如果过程中有事务是不是不能单步?应为我的过程原来有事务,但是我一单步到select就报错了
然后我把事务去掉就能走远点,这是为什么?

还有我单步的时候看到@@connections这个参数,这是不是写的连接数?我发现我每连一次它就+1,是不是我的连接还在???如果是的话意思是每次调试都没有释放资源,或者说是关闭连接?
...全文

相关推荐

评论 2
收藏 已收藏
分享
返回顶部
bigbigcai
应用实例 27,579 成员 68,540 内容