Hello,
I did some tests and the following example produces three times the same record in the data base, but the input records are diffrent!
procedure TfrmMain.btnDirectLoadClick(Sender: TObject);
var
Loader: TOracleDirectPathLoader;
i, Row, BuffLen: Integer;
sBuff1: String;
dBuff1: Double;
begin
//
// Create a Loader at run time
Loader := TOracleDirectPathLoader.Create(nil);
try
// Set the session and table name
Loader.Session := DataModule1.OracleSession1;
Loader.TableName := 'MUAI_CONTACT';
// Get the default columns for the record_data table
//Loader.GetDefaultColumns(True);
Loader.Columns.Add('WEB_EDITED');
Loader.ColumnByName('WEB_EDITED').DataType := dpString;
Loader.ColumnByName('WEB_EDITED').DataSize := 1020;
Loader.Columns.Add('CONTACT_ID');
Loader.ColumnByName('CONTACT_ID').DataType := dpFloat;
Loader.ColumnByName('CONTACT_ID').DataSize := 8;
Loader.Columns.Add('RN_DESCRIPTOR');
Loader.ColumnByName('RN_DESCRIPTOR').DataType := dpString;
Loader.ColumnByName('RN_DESCRIPTOR').DataSize := 1020;
// Prepare the loader
Loader.Prepare;
// Process all data in batches of records
DataModule1.ADOTableFrom.First;
Row := 0;
//-- DataModule1.ADOTableFrom.RecordCount - 1
for i := 0 to 2 do
begin
// Copy one record to the array
sBuff1 := DataModule1.ADOTableFrom.Fields[0].AsString;
BuffLen := Length(sBuff1);
Loader.ColumnByName('WEB_EDITED').SetData(Row, @sBuff1[1], BuffLen);
dBuff1 := DataModule1.ADOTableFrom.Fields[1].AsFloat;
BuffLen := 8;
Loader.ColumnByName('CONTACT_ID').SetData(Row, @dBuff1, BuffLen);
sBuff1 := DataModule1.ADOTableFrom.Fields[2].AsString;
BuffLen := Length(sBuff1);
Loader.ColumnByName('RN_DESCRIPTOR').SetData(Row, @sBuff1[1], BuffLen);
Inc(Row);
DataModule1.ADOTableFrom.Next;
// The array is filled, or we have preocessed all records:
// load this batch of records
if (Row = Loader.MaxRows) or (i = 2 ) then //* Records.Count - 1 *//
begin
try
Loader.Load(Row);
except
// In case of an error: show where things went wrong
// and abort the load operation
on E:EOracleError do
begin
ShowMessage(E.Message + #13#10 +
'Row = ' + IntToStr(Loader.LastRow) + #13#10
+ 'Col = ' + IntToStr(Loader.LastColumn));
Loader.Abort;
raise;
end;
end;
Row := 0;
end;
end;
// Commit the loaded data
Loader.Finish;
finally
FreeAndNil(Loader);
end;
//
end;