Insufficient memory with ClientDataSet.SaveToFile

2

I need to generate a XML file of a table of 500,000 rows and 200 columns using ADQuery of FireDAC and TClientDataSet saving with

ClientDataSet.SaveToFile(Arquivo).

I need to write with ClientDataSet to remain the same structure as XML .

My code is:

ClientDataSet.Close;
Query.Sql.Clear;
Query.Sql.Add ("Select * from something");
ClientDataSet.Open;
ClientDataSet.SaveToFile("destination_folder.xml");

But when saving, insufficient memory error occurs.

How could I save this file? How could I write ClientDataSet to multiple files?

    
asked by anonymous 11.03.2016 / 18:54

1 answer

1

Good afternoon,

Try using the FDMemTable component of FireDAC instead of the TClientDataSet and FDQuery of FireDAC, it also saves with the same structure and then just pass the path to receive the content. With the following code:

if (FDQuery.Active) then
    FDQuery.Close;
FDQuery.SQL.Clear;
FDQuery.SQL.Add('SELECT * FROM SOMETHING');
FDQuery.Open;
FDMemTable.Data := FDQuery1.Data;
FDMemTable.SaveToFile('destination_folder.xml');
    
11.03.2016 / 20:04