UniDAC driver: Query FetchAll + Unidirectional

In the UniDAC documentation, it is written, that if FetchAll is enabled, Unidirectional cannot be enabled.

Currently in the UniDAC DA driver, Unidirectional is enabled, while FetchAll is disabled.

If FetchAll is disabled, another database connection will be needed (I think), to get all data.

I believe in the case of DA, all rows will be needed anyway, before data is returned to the client.
So currently I use the following code changes (for Query and Stored Procedure):

function TDAEUniDACQuery.CreateDataset(…)…
begin
***Corrected: TUniQuery(result).Unidirectional := False;
***Added: TUniQuery(result).SpecificOptions.Values[‘FetchAll’] := ‘True’;
end;

Could this be added to your DA source code?

DA allows to return only specific number of records: http://wiki.remobjects.com/wiki/TDAMemDataTable_Class#MaxRecords so your code can cause superfluous delays when client asks to return only few records from very big table.

OK. The default MaxRecords is -1, so I guess in that case it will be OK to fetch all.

you can create descendant of UniDAC driver and override few methods like :

function TMyDAEUniDACConnection.GetDatasetClass: TDAEDatasetClass;
begin
  Result := TMyDAEUniDACQuery;
end;

function TDAEUniDACQuery.CreateDataset(aConnection: TDAEConnection): TDataset;
begin
  result := inherited CreateDataset(aConnection);
  TUniQuery(result).Unidirectional := False;
  TUniQuery(result).SpecificOptions.Values['FetchAll'] := 'True';
end;

function GetDriverObject: IDADriver;
begin
  if (_driver = nil) then _driver := TMyDAEUniDACDriver.Create(nil);
  result := _driver;
end;

initialization
  _driver := nil;
  UnregisterDriverProc(uDAUniDACDriver.GetDriverObject);
  RegisterDriverProc(GetDriverObject);
finalization
  UnregisterDriverProc(GetDriverObject);
  FreeAndNIL(_driver);

The reason for this would be to avoid having to correct the code, every time I upgrade DA to a newer version?

Right now I just change the uDAUniDACDriver.pas file.

But this would be a better solution, thx.

yes. with above solution you shouldn’t update uDAUniDACDriver.pas