咏南中间件支持客户端控制数据库事务
咏南中间件支持客户端控制数据库事务
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;
本文来自博客园,作者:{咏南中间件},转载请注明原文链接:https://www.cnblogs.com/hnxxcxg/p/13691290.html