zoukankan      html  css  js  c++  java
  • 同一连接内事务名只有一个

    参见:http://www.cnblogs.com/hongten/archive/2011/06/18/2084036.html

    在一系列嵌套的事务中用一个事务名给多个事务命名对该事务没有什么影响。系统仅登记第一个(最外部的)事务名。回滚到其它任何名字(有效的保存点名除外)都会产生错误

    事实上,任何在回滚之前执行的语句都没有在错误发生时回滚。这语句仅当外层的事务回滚时才会进行回滚。

    例:内部事务回滚SQL server 报错。

    begin tran t1 
    Insert into demo2(name,age) values('lis',1)
    ---Second Trans
    begin transaction t2 

    insert into demo values('BB','B term')
    rollback transaction t2
    ----In the first trans .
    Insert into demo2(name,age) values('lis',2)
    commit transaction t1

    事务t2回滚时报错:

    --Server: Msg 6401, Level 16, State 1, Line 6
    --Cannot roll back t2. No transaction or savepoint of that name was found.

    例: 内部事务提交SQL server 不会报错。

    begin tran t1 
    Insert into demo2(name,age) values('lis',1)
    begin transaction t2 
    insert into demo values('BB','B term')
    commit transaction t2  --正确
    ----In the first trans .
    Insert into demo2(name,age) values('lis',2)
    commit transaction t1

  • 相关阅读:
    [算法]最长子数组问题
    [算法]K-SUM problem
    selenium-远程调用
    pytest-fixture
    Ubuntu18.04中安装virtualenv和virtualenvwrapper
    shell
    mac保存远程链接
    css
    js基础
    css基础
  • 原文地址:https://www.cnblogs.com/jshchg/p/2125589.html
Copyright © 2011-2022 走看看