D
decade
Unregistered / Unconfirmed
GUEST, unregistred user!
请问这个存储过程,最后一条sql 语句执行出错的情况下,是否能 RollBack ?
CREATE PROCEDURE [dbo].[Material_Post] @PostUser varChar(16) AS
Begin
Begin Transaction
Insert Into Tuico_BackMaterStock Select * From Tuico_MaterStock Where Post_Date Is Null
Update Tuico_BackMaterStock Set Post_Date=GetDate() ,Post_User=@PostUser Where Post_Date Is Null
//以下语句如果产生异常,能否正常回滚?
Update Tuico_MaterStock Set Post_Weigh=Stock_Weigh,Input_Weight=0,SendOut_Weight=0,Stock_Year=Year(GetDate()),Stock_Month=Stock_Month+1
if @@Error<>0
Begin
RaisError('库存结转出现错误,操作被取消!',16,1)
RollBack Transaction
End
Else
Commit Transaction
End
CREATE PROCEDURE [dbo].[Material_Post] @PostUser varChar(16) AS
Begin
Begin Transaction
Insert Into Tuico_BackMaterStock Select * From Tuico_MaterStock Where Post_Date Is Null
Update Tuico_BackMaterStock Set Post_Date=GetDate() ,Post_User=@PostUser Where Post_Date Is Null
//以下语句如果产生异常,能否正常回滚?
Update Tuico_MaterStock Set Post_Weigh=Stock_Weigh,Input_Weight=0,SendOut_Weight=0,Stock_Year=Year(GetDate()),Stock_Month=Stock_Month+1
if @@Error<>0
Begin
RaisError('库存结转出现错误,操作被取消!',16,1)
RollBack Transaction
End
Else
Commit Transaction
End