EventId: String;
The EventId property determines identifier of the event called on occurring ETL task execution error.
To determine a method of handling the errors, which may occur on data loading, use the IEtlPlainDataCopy.ActionOnProblem property.
The custom events list is created in the IMetabaseCustomExtender.Events collection.
Executing the example requires:
An ETL task with the ETL identifier and a table with the TBL identifier in the repository.
Fields of the table used in the example:
KEY. Field of integer type.
COUNTRY_NAME. Field of string type.
OWNER. Field of string type.
The C:\ETL_imp.txt text file in the file system.
The first four lines of a text file used in the example:
"Key","Country Name","Owner"
512,"Afghanistan",3
914,"Albania",1
612,"Algeria",2
A custom event with the CUSTOM_EVENT identifier is also added to the repository.
Add links to the Metabase, Etl, Dt, Db, Andy, Drawing system assemblies.
Sub UserProc;
Var
MB: IMetabase;
Task: IEtlTask;
CopyObj: IEtlPlainDataCopy;
FProvider: IDtTextProvider;
Tab: IDatasetModel;
FConsumer: IDtMetabaseConsumer;
ProvFields, ConsFields: IDtFieldDefinitions;
i: Integer;
WxConsumer: IWxRectangle;
WxETLConsumer: IWxEtlObject;
Begin
MB := MetabaseClass.Active;
Task := MB.ItemById("ETL").Edit As IEtlTask;
// Create object that copies data
CopyObj := Task.Create(EtlObjectType.PlainDataCopy) As IEtlPlainDataCopy;
CopyObj := CopyObj.Edit;
// Set up data source parameters
FProvider := New DtTextProvider.Create As IDtTextProvider;
FProvider.File := "C:\ETL_imp.txt";
FProvider.DelimitedColumnDelimiter := ",";
FProvider.HeaderRow := 1;
FProvider.FormatType := DtTextFormatType.Delimited;
FProvider.RangeHasHeader := True;
FProvider.RangeFirstRow := 1;
COpyObj.Provider := FProvider;
// Set up data consumer parameters
FConsumer := New DtMetabaseConsumer.Create;
Tab := MB.ItemById("TBL").Edit As IDatasetModel;
FConsumer.Dataset := Tab;
CopyObj.Consumer := FConsumer;
// Bind data of source and consumer
ProvFields := FProvider.Fields;
ConsFields := FConsumer.Fields;
CopyObj.AutoLink;
For i := 0 To ProvFields.Count - 1 Do
If Not CopyObj.IsLinked(ProvFields.Item(i).Name, ConsFields.Item(i).Name) Then
CopyObj.AddLink(ProvFields.Item(i).Name, ConsFields.Item(i).Name);
End If;
End For;
// Clear data consumer
CopyObj.ClearConsumer := True;
// Handle errors
CopyObj.ActionOnProblem := EtlActionOnProblem.DiscardRecordsInTransaction;
CopyObj.SaveInvalidRecs := True;
CopyObj.InvalidRecsFileName := "Errors";
CopyObj.UseStopLimit := True;
CopyObj.StopLimit := 2;
CopyObj.CommitCount := 10;
CopyObj.EventId := "CUSTOM_EVENT";
// Save object that copies data
CopyObj.Save;
// Create a visual object
WxConsumer := Task.Workspace.CreateRectangle;
WxETLConsumer := New WxEtlObject.Create;
WxETLConsumer.EtlObject := CopyObj;
WxConsumer.Style.TextPosition := WxTextPosition.Bottom;
WxConsumer.Style.PictureMarginTop := -10;
WxConsumer.PinPosition := New GxPointF.Create(50, 50);
WxConsumer.Extension := WxETLConsumer As IWxShapeExtension;
// Save ETL task object
(Task As IMetabaseObject).Save;
End Sub UserProc;
After executing the example a new object that copies data is created in ETL task. Copying is executed from a text file into a repository table. The following settings are determined for the Copy Data object:
Fields of data source and data consumer are linked automatically.
If any link between fields of data source and data consumer cannot be created automatically, it is added manually.
If errors occur on loading, records within one transaction will be ignored.
If errors occur, all skipped records on executing the task are saved into the Errors file.
If more than two errors occur, task execution is stopped.
10 records are processed within one transaction.
If errors occur on task execution, the Start Loading event is called.
See also: