<div class="codetitle"><a style="CURSOR: pointer" data="49123" class="copybut" id="copybut49123" onclick="doCopy('code49123')"> 代码如下:<div class="codebody" id="code49123"> create procedure test_tran as set xact_abort on -----用@@error判断,对于严重的错误,系统根本就不会执行随后对@@error的判断,会直接终止执行。所以设置set xact_abort on 是必要的 BEGIN TRANSACTION RemoteUpdate insert psn_degree values(22,'test') select 1/0 IF @@error !=0 BEGIN ROLLBACK TRANSACTION RemoteUpdate RAISERROR('出错!网络速度慢或断线!',16,16) WITH SETERROR RETURN ---没有return 将继续向下执行 end else begin COMMIT TRANSACTION RemoteUpdate end 也可更改为: <div class="codetitle"><a style="CURSOR: pointer" data="40837" class="copybut" id="copybut40837" onclick="doCopy('code40837')"> 代码如下:<div class="codebody" id="code40837"> IF @@error !=0 BEGIN ROLLBACK TRANSACTION RemoteUpdate RAISERROR('出错!网络速度慢或断线!',16) WITH SETERROR RETURN ---没有return 将继续向下执行 end COMMIT TRANSACTION RemoteUpdate
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|