IEtlPlainDataCopy.RemoveLink

Syntax

RemoveLink(ProviderField: String; ConsumerField: String);

Parameters

ProviderField - identifier of data source field.

ConsumerField - identifier of data consumer field.

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

Description

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

Example

The example displays copying data from a text file to a repository table. Executing the example requires that the repository contains an ETL task with the OBJ_ETL identifier and a table with the OBJ_TBL identifier. The file system must also contain the text file C:\ETL_imp.txt.

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 the 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 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. The link by the OWNER field is removed. Thus, copying is performed only by the KEY and COUNTRY_NAME fields. If errors occur on loading, records within one transaction will be ignored. 10 records are processed within one transaction. After the copied object is saved, ETL task will be run for execution.

See also:

IEtlPlainDataCopy