I am using array DML operations to speed insert of large number of records into SQL database. The principle is described here. Sample code how this functionality is used:
TFDQuery *FDQuery1;
...
FDQuery1->SQL->Text = "insert into MyTab values (:p1, :p2, :p3)";
// here FDQuery1->Params collection is filled by 3 parameters
const int array_size = 100;
FDQuery1->Params->ArraySize = array_size;
FDQuery->Prepared = true;
for(int i = 0; i < array_size; i++)
{
FDQuery1->Params[0]->AsIntegers[i] = i;
FDQuery1->Params[1]->AsStrings[i] = "qwe";
FDQuery1->Params[2]->Clear(i);
}
FDQuery1->Execute(array_size);
Essentially it means that instead of calling database engine client function for every row inserted, I first prepare data I need to insert as array. Typical size of array is 1000 items. Then I call client function with array as parameter. Unfortunately nowhere in documentation is described when is memory for array of parameters is released. Is it done when I unprepare query ?
TFDQuery *query;
...
query->Prepared = false;
Or is it done when I close the query ?
query->Close();
Or is it done when I set array size to 1 ?
query->Params->ArraySize = 1