zoukankan      html  css  js  c++  java
  • DELPHI事务


    --测试环境
    create table table1(id int primary key)
    insert table1 select 1
    union  all    select 2
    --查看表
    select * from table1
    --操作A(执行错误后,事务没有回滚)
    begin tran
    delete From table1 where id=1
    Insert into A(Field1) values(3) --事务没有回滚
    commit tran
    --操作B(执行错误后,事务回滚)
    BEGIN TRY
    begin tran//创建还原点
    delete From table1 where id=1
    Insert into A(Field1) values(3)
    commit tran//提交数据
    END TRY
    BEGIN CATCH
     
    ROLLBACK//遇到问题,捕获后回滚到还原点
    END CATCH

      con1.BeginTrans;
      try
         with qry1 do
        
    begin
           close;
           sql.clear;
           sql.Text:
    ='delete From table1 where id=1 ;Insert into table1(Field1) values(3)';
           ExecSQL;
        
    end;
         con1.CommitTrans;
      except
         con1.RollbackTrans;
     
    end;

  • 相关阅读:
    2016九大前端必备动画库
    关于页面跳转,登录刷新
    关于换行
    c++ vector 的使用
    c++ namespace的使用
    u盘文件系统故障的修复方法
    nfs的使用
    ubuntu 无声音的解决
    Yii 视图中的 $this
    Apache vhost
  • 原文地址:https://www.cnblogs.com/chengxin1982/p/1357139.html
Copyright © 2011-2022 走看看