DA中直接运行SQL命令,并返回影响行数

1 、 客户端直接运行SQL命令 , 使用TDARemoteCommand
2 、 服务器端直接运行SQL命令 , 使用TDALocalCommand

function DeleteRowFromTable1(aID: integer): integer;
var
  lCommand: TDALocalCommand;
  linp, lout: DataParameterArray;
  i: integer;
begin
  try
    lCommand := TDALocalCommand.Create(nil);
    lCommand.ServiceName := 'MyService';
    linp := DataParameterArray.Create;
    try
      with linp.Add do
      begin
        Name := UTF8Encode('ID');
        Value := aID;
      end;
      lCommand.Execute('DeleteRow', linp, lout);
      if lout <> nil then
        for i := 0 to lout.Count - 1 do
          if UTF8ToString(lout[i].Name) = 'ErrorCode' then
            Result := lout[i].Value;
    finally
      linp.Free;
      lout.Free;
    end;
  finally
    lCommand.Destroy;
  end;
end;
原文地址:https://www.cnblogs.com/leonkin/p/3208676.html