Insufficient memory with Clientdataset.Savetofile

Asked

Viewed 574 times

1

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

ClientDataSet.SaveToFile(Arquivo).

I need to record with the ClientDataSet to remain the same structure of 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 occurs insufficient memory error.

How could I record this file? How could I record the ClientDataSet in multiple files?

1 answer

2


Good Afternoon,

Try using Firedac’s Fdmemtable component instead of Tclientdataset and Firedac’s Fdquery, 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');
  • Thank you for your @Jrudolf tip, but in the same way it burst the memory. I split Query into smaller selects and smaller file recordings.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.