KeyFieldNames: String;
KeyFieldNames: string;
The KeyFieldNames property determines fields to find identical records in a data source and a data consumer.
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.
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(20, 20 );
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.
The requirements and result of the Fore.NET example execution match with those in the Fore example.
Imports Prognoz.Platform.Interop.Andy;
Imports Prognoz.Platform.Interop.Dal;
Imports Prognoz.Platform.Interop.Db;
Imports Prognoz.Platform.Interop.Drawing;
Imports Prognoz.Platform.Interop.Dt;
Imports Prognoz.Platform.Interop.Etl;
…
Public Shared Sub Main(Params: StartParams);
Var
Metabase: IMetabase;
MObj: IMetabaseObject;
EtlTask: IEtlTask;
EtlConsumer: IEtlPlainDataConsumer;
Fields: IEtlPlainFields;
Field: IEtlPlainField;
MBConsumer: IDtMetabaseConsumer;
Tab: IDatasetModel;
Begin
Metabase := Params.Metabase;
MObj := Metabase.ItemById["ETL"].Edit();
EtlTask := MObj As IEtlTask;
Tab := Metabase.ItemById["TABLE"].Bind() As IDatasetModel;
EtlConsumer := EtlTask.Create(EtlObjectType.eotPlainDataMetabaseConsumer) 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.ddtString;
Field := Fields.Add();
Field.Id := "Id";
Field.Name := "Id";
Field.DataType := DbDataType.ddtInteger;
Field := Fields.Add();
Field.Id := "Order";
Field.Name := "Order";
Field.DataType := DbDataType.ddtInteger;
Fields.Save();
EtlConsumer.KeyFieldNames := "ID;NAME";
EtlConsumer.Save();
CreateWX(EtlConsumer, EtlTask);
MObj.Save();
End Sub;
Public Shared Sub CreateWX(CopyObj: IEtlPlainDataConsumer; etltask: IEtltask);
Var
WxDataTrans: IWxRectangle;
WxETLDataTrans: WxETLObject = New WxETLObjectClass();
OutPoint: GxPointF = New GxPointFClass();
Begin
WxDataTrans := EtlTask.Workspace.CreateRectangle();
WxDataTrans.Id := CopyObj.Id;
WxETLDataTrans.EtlObject := CopyObj;
WxDataTrans.Style.TextPosition := WxTextPosition.wtpBottom;
WxDataTrans.Style.PictureMarginTop := -10;
OutPoint := WxDataTrans.PinPosition;
OutPoint.Create(20, 20);
WxDataTrans.Extension := WxETLDataTrans As IWxShapeExtension;
End Sub CreateWX;
See also: