zoukankan      html  css  js  c++  java
  • 事务拼接

     1 StringBuilder strSql = new StringBuilder();
     2 strSql.AppendLine("begin tran tran_AddUserInfo --开始事务   ");
     3 strSql.AppendLine("declare @tran_error int; ");
     4 strSql.AppendLine("set @tran_error=0; ");
     5 strSql.AppendLine("begin try ");
     6 strSql.AppendLine("update PC_USER_T set Email='22' where id=3397 ");
     7 strSql.AppendLine("update PC_USER_T set Email='111212111' where id=3396 ");
     8 strSql.AppendLine("end try ");
     9 strSql.AppendLine("begin catch ");
    10 strSql.AppendLine("  set @tran_error=@tran_error+1; --加分号或不加都能正常执行 ");
    11 strSql.AppendLine("end catch ");
    12 strSql.AppendLine("if(@tran_error>0) ");
    13 strSql.AppendLine("begin ");
    14 strSql.AppendLine("  rollback tran; --执行出错,回滚事务(不指定事务名称) ");
    15 strSql.AppendLine("  print @tran_error; ");
    16 strSql.AppendLine("end  ");
    17 strSql.AppendLine("else ");
    18 strSql.AppendLine("begin ");
    19 strSql.AppendLine("  commit tran; --没有异常,提交事务(不指定事务名称) ");
    20 strSql.AppendLine("  print @tran_error; ");
    21 strSql.AppendLine("end ");
  • 相关阅读:
    告别被拒,如何提升iOS审核通过率(上篇)
    Linux 学习总结(二)
    Linux 学习总结(一)
    Navicat for mysql 破解
    IDEA2017-破解方法
    VmWare15 许可证
    Java 中的锁
    JVM 参数调优
    Tcp/Ip 三次握手与四次挥手
    Java 集合面试总结
  • 原文地址:https://www.cnblogs.com/xujunbao/p/8658082.html
Copyright © 2011-2022 走看看