IEtlPlainDataConsumer.KeyFieldNames

Syntax

KeyFieldNames: String;

Description

The KeyFieldNames property determines fields to find identical records in a data source and a data consumer.

Comments

A line that contains fields identifiers separated with semicolon should be passed to the property. This property is relevant only if data consumer is configured on repository table. Below is the example of records identification. A data source and a data consumer are configured on two repository tables that are identical by structure. Each table has three fields: Code, Name and Order. For data consumer records update is set by the Code and Name fields. Under such settings if in a source table in the current record the value of the Order field changes, and values of the Code and Name fields remain unchanged, after data loading in a consumer table in a corresponding record (the Code and Name values match with values in a source) only the Order value changes. If records update by the Code and Name fields is not on for a consumer, after data loading a new record appears in a consumer table.

Example

Executing the example requires that the repository contains an ETL task with the ETL identifier and a table with the Table identifier. This table represents a data consumer.

Add links to the Andy, Dal, Db, Drawing, Dt, Etl, Metabase system assemblies.

Sub  UserProc;
Var
    Metabase: IMetabase;
    MObj: IMetabaseObject;
    EtlTask: IEtlTask;
    EtlConsumer: IEtlPlainDataConsumer;
    Fields: IEtlPlainFields;
    Field: IEtlPlainField;
    MBConsumer: IDtMetabaseConsumer;
    Tab: IDatasetModel;
Begin
    Metabase := MetabaseClass.Active;
    MObj := Metabase.ItemById(
"ETL" ).Edit;

    EtlTask := MObj  As  IEtlTask;
    Tab := Metabase.ItemById(
"TABLE").Bind As  IDatasetModel;
    EtlConsumer := EtlTask.Create(EtlObjectType.PlainDataMetabaseConsumer) 
As  IEtlPlainDataConsumer;
    EtlConsumer := EtlConsumer.Edit;
    EtlConsumer.ClearConsumer := 
False ;
    EtlConsumer.Id := 
"MB_Consumer" ;
    EtlConsumer.Name := 
"Repository data consumer" ;
    MBConsumer := EtlConsumer.Consumer 
As  IDtMetabaseConsumer;
    MBConsumer.Dataset := Tab;
    Fields := EtlConsumer.PlainInput.Fields;
    Fields := Fields.Edit;

    Field := Fields.Add;
    Field.Id := 
"Name" ;
    Field.Name := 
"Name" ;
    Field.DataType := DbDataType.String;
    Field := Fields.Add;
    Field.Id := 
"Id" ;
    Field.Name := 
"Id" ;
    Field.DataType := DbDataType.Integer;
    Field := Fields.Add;
    Field.Id := 
"Order" ;
    Field.Name := 
"Order" ;
    Field.DataType := DbDataType.Integer;
    Fields.Save;

    EtlConsumer.KeyFieldNames :=  "ID;NAME" ;
    EtlConsumer.Save;
    CreateWX(EtlConsumer, EtlTask);
    MObj.Save;
End Sub  UserProc;

Sub  CreateWX(CopyObj: IEtlPlainDataConsumer; etltask: IEtltask);
Var
    WxDataTrans: IWxRectangle;
    WxETLDataTrans: IWxEtlObject;
Begin
    WxDataTrans := EtlTask.Workspace.CreateRectangle;
    WxDataTrans.Id := CopyObj.Id;

    WxETLDataTrans :=  New  WxEtlObject.Create;
    WxETLDataTrans.EtlObject := CopyObj;
    WxDataTrans.Style.TextPosition := WxTextPosition.Bottom;
    WxDataTrans.Style.PictureMarginTop := -
10 ;
    WxDataTrans.PinPosition := 
New GxPointF.Create(2020 );
    WxDataTrans.Extension := WxETLDataTrans 
As  IWxShapeExtension;
End Sub CreateWX;

After executing the example (UserProc) a repository data consumer, for which records update by the Id and Name fields is configured, is created for ETL task.

See also:

IEtlPlainDataConsumer