IEtlPlainDataCopy.RemoveLink

Syntax

RemoveLink(ProviderField: String; ConsumerField: String);

Parameters

ProviderField is the identifier of data source field.

ConsumerField is the identifier of data consumer field.

NOTE. Parameters values are case sensitive. Fields identifiers must be set in upper case.

Description

The RemoveLink method removes the link between the specified data source and data consumer fields.

Example

In the example copying data from a text file to a repository table is considered. Executing this example requires an ETL task with the OBJ_ETL identifier and a table with the OBJ_TBL identifier in repository. Also a text file C:\ETL_imp.txt should exist in a 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",

Fields of the table used in the example:

Sub Main;

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("OBJ_ETL").Edit As IEtlTask;

// Create an object that copies data

CopyObj := Task.Create(EtlObjectType.PlainDataCopy) As IEtlPlainDataCopy;

CopyObj := CopyObj.Edit;

//Configuration of 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;

//Configuration of data consumer parameters

FConsumer := New DtMetabaseConsumer.Create;

Tab := MB.ItemById("OBJ_TBL").Edit As IDatasetModel;

FConsumer.Dataset := Tab;

CopyObj.Consumer := FConsumer;

// Data binding of a 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;

//Removal of a link by the field OWNER

CopyObj.RemoveLink("OWNER", "OWNER");

// Clearance of data consumer

CopyObj.ClearConsumer := True;

//Error treatment

CopyObj.ActionOnProblem := EtlActionOnProblem.DiscardRecordsInTransaction;

CopyObj.CommitCount := 10;

// Saving of an object that copies data

CopyObj.Save;

//Beginning of visual object creation

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;

//End of visual object creation

//Task execution

Task.Execute(Null);

//Saving of ETL task object

(Task As IMetabaseObject).Save;

End Sub Main;

After executing this example a new object that copies data is created in ETL task. Copying is performed from a text file into a repository table. Fields of source and consumer are linked automatically. If any link between fields of a source and consumer cannot be created automatically, it is added manually. Link by the OWNER field is removed. Thus, copying is performed only by the KEY and COUNTRY_NAME fields. If errors occur while loading, records within one transaction will be ignored. 10 records could be processed within one transaction. After copied object is saved ETL task will be run for execution.

See also:

IEtlPlainDataCopy