数据库
首页 > 数据库> > 咏南中间件支持客户端控制数据库事务

咏南中间件支持客户端控制数据库事务

作者:互联网

咏南中间件支持客户端控制数据库事务

procedure TForm1.Button3Click(Sender: TObject);
var
  transId: string;
begin
  // 执行非查询SQL
  transId := CreateClassID;  //事务id,必须是唯一的
  ynDataSet1.BeginTrans(transId); // 开启事务

  ynDataSet1.Close;
  ynDataSet1.SQL.Clear;
  ynDataSet1.SQL.Add('update tunit set unitname=''hh'' where unitid=:unitid');
  ynDataSet1.Parameters.ParamByName('unitid').AsString := '1';
  ynDataSet1.ExecSQL(transId);

  ynDataSet1.Close;
  ynDataSet1.SQL.Clear;
  ynDataSet1.SQL.Add('update tgoods set goodsname=''hh'' where goodsid=:goodsid');
  ynDataSet1.Parameters.ParamByName('goodsid').AsString := '100050';
  ynDataSet1.ExecSQL(transId);

  ynDataSet1.CommitTrans(transId);     //提交事务
//  ynDataSet1.RollbackTrans(transId);   //回滚事务
end;

  

标签:事务,unitid,中间件,goodsid,ynDataSet1,SQL,咏南,transId,客户端
来源: https://www.cnblogs.com/hnxxcxg/p/13691290.html