实际上,我对在存储过程中使用嵌套事务有点困惑。 我需要在一个主要程序中调用两个/三个程序。嵌套存储过程中的嵌套事务
如:
Begin try
Begin Tran -- 1st level transcation
Procedure 1 --will be executed
Procedure 2 --will be executed
End tran -- 1st level transcation
End try
Begin Catch
Rollback tran
End Catch
PROCEDURE 1:
BEGIN TRAN TRAN1
///scripts
COMMIT TRAN TRAN1
PROCEDURE 2:
BEGIN TRAN TRAN2
///scripts
COMMIT TRAN TRAN2
我在做它在一个正确的方式?
时PROC1或PROC2失败会发生什么? –
无法回滚TRAN1。没有找到该名称的事务或保存点。 –