IEtlPlainDataCopy.RemoveLink

Syntax

RemoveLink(ProviderField: String; ConsumerField: String);

Parameters

ProviderField. Data provider field identifier.

ConsumerField. Data consumer field identifier.

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

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 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("OBJ_ETL").Edit As IEtlTask;
    // Create an 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("OBJ_TBL").Edit As IDatasetModel;
    FConsumer.Dataset := Tab;
    CopyObj.Consumer := FConsumer;
    // Link source and consumer data
    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;
    //Unbind by the "OWNER" field
    CopyObj.RemoveLink("OWNER""OWNER");
    // Clear data consumer
    CopyObj.ClearConsumer := True;
    //Handle errors
    CopyObj.ActionOnProblem := EtlActionOnProblem.DiscardRecordsInTransaction;
    CopyObj.CommitCount := 10;
    // Save the object that copies data
    CopyObj.Save;
    //Start 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(5050);
    WxConsumer.Extension := WxETLConsumer As IWxShapeExtension;
    //End of visual object creation
    //Execute task
    Task.Execute(Null);
    //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 performed from a text file into a repository table. Fields of data provider and data consumer are bound automatically. If any link between fields of data source and data consumer cannot be created automatically, it can be 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