Re: Help optimize Dataset copy code



Hello

Nothing about ADO :)

But using other DAC's, like the AnyDAC, you can speedup your data loading. Following is the example of how to use
Array DML to load data from one to another of supported DBMS's:

qSrc.SQL.Text := 'select f1, f2, ... from srctab';
qSrc.FetchOptions.RowsetSize := 1000;
qSrc.FetchOptions.Unidirectional := True;

qDest.SQL.Text := 'insert into desttab values(:f1, :f2, ...)';
qDest.Params.ArraySize := 1000;

qSrc.DisableControls;
try
qSrc.Open;
iCurRow := 0;
while not qSrc.Eof do begin
qDest.Params[0].AsIntegers[iCurRow] := qSrc.Fields[0].AsInteger;
qDest.Params[1].AsStrings[iCurRow] := qSrc.Fields[0].AsString;
......
Inc(iCurRow);
if iCurRow = qDest.Params.ArraySize then begin
qDest.Execute(qDest.Params.ArraySize, 0);
iCurRow := 0;
end;
qSrc.Next;
end;
if iCurRow > 0 then
qDest.Execute(iCurRow, 0);
finally
qSrc.EnableControls;
end;

--
With best regards,
Dmitry Arefiev
AnyDAC Team

RemObjects Software
The Infrastructure Company
http://www.remobjects.com

.