IRdsExportSchemaAttribute.UpdateDetailTableMode

Fore Syntax

UpdateDetailTableMode: RdsUpdateDetailTableMode;

Fore.NET Syntax

UpdateDetailTableMode: Prognoz.Platform.Interop.Rds.RdsUpdateDetailTableMode;

Description

The UpdateDetailTableMode property determines the way of records update in a table used to export values of a multiple attribute.

Comments

By default UpdateDetailTableMode = RdsUpdateDetailTableMode.Recreate, that is, while export all records are deleted from a child table, values of a multiple attribute are exported.

Fore Example

Executing the example requires that the repository contains tables with the OBJ_EXP and OBJ_EXP_VALUE identifiers. There must be also the MDM repository with the RDS_REPO identifier that contains the MDM dictionary with the EXPORT identifier. This dictionary has an attribute with the ATTRIBUTE identifier that may have multiple values and is connected with another dictionary. Identifiers and field types of the OBJ_EXP table and of the EXPORT dictionary match. The OBJ_EXP table must also have a field of integer type with the KEY_EXP identifier. The OBJ_EXP_VALUE table must contain fields of integer type with the following identifiers: KEYFIELD, VALUEFIELD, ORDERFIELD.

Add links to the Metabase, Rds, Db system assemblies.

Sub UserProc;
Var
    MB: IMetabase;
    MObj: IMetabaseObject;
    Dict: IRdsDictionary;
    Export: IRdsExportSchemas;
    SchemaExport: IRdsExportSchema;
    Attrs: IRdsAttributes;
    TableObj: IMetabaseObjectDescriptor;
    Table: ITable;
    SchemaExportAttr: IRdsExportSchemaAttribute;
    DictInst: IRdsDictionaryInstance;
Begin
    MB := MetabaseClass.Active;
    MObj := MB.ItemByIdNamespace("EXPORT", MB.ItemById("RDS_REPO").Key).Edit;
    Dict := MObj As IRdsDictionary;
    Attrs := Dict.Attributes;
    Export := Dict.ExportSchemas;
    SchemaExport := Export.Add;
    SchemaExport.Id := MB.GenerateId("Export1");
    SchemaExport.Name := Export scheme #1;
    SchemaExport.Mappings(Attrs.Key).FieldName := "Key";
    SchemaExport.Mappings(Attrs.Name).FieldName := "Name";
    SchemaExport.Mappings(Attrs.Order).FieldName := "Ord";
    SchemaExport.Mappings(Attrs.ParentKey).FieldName := "Parent_key";
    TableObj := MB.ItemById("OBJ_EXP");
    Table := TableObj.Bind As ITable;
    SchemaExport.TableObject := TableObj;
    SchemaExport.TableName := Table.NativeName;
    SchemaExportAttr := SchemaExport.Mappings(Attrs.FindById("ATTRIBUTE"));
//Binding attribute that has multiple values
    TableObj := MB.ItemById("OBJ_EXP_VALUE");
    Table := TableObj.Bind As ITable;
    SchemaExportAttr.DetailTableObject := TableObj;
    SchemaExportAttr.DetailTable := Table.NativeName;
    SchemaExportAttr.FieldName := "KEY_EXP";
    SchemaExportAttr.KeyField := "KEYFIELD";
    SchemaExportAttr.ValueField := "VALUEFIELD";
    SchemaExportAttr.OrderField := "ORDERFIELD";
    SchemaExportAttr.UpdateDetailTableMode := RdsUpdateDetailTableMode.Update;
    MObj.Save;
    DictInst := Dict.Open(Null);
    DictInst.ExportData(SchemaExport);
End Sub UserProc;

After executing the example a new export scheme is created in the MDM dictionary. Attribute values of the EXPORT dictionary are exported in same-name fields of the OBJ_EXP table. Multiple values of the ATTRIBUTE attribute are imported from the OBJ_EXP_VALUE table. Export will be executed. On export, values of the ATTRIBUTE attribute and records contained in the OBJ_EXP_VALUE table are associated. If a record that corresponds to the value of attribute is not found in the table, it is added there. If a record that does not correspond to any value of attribute is found in the table, it is deleted. If a record that corresponds with attribute value is found in the table, it is updated.

Fore.NET Example

Executing the example requires that the repository contains tables with the OBJ_EXP and OBJ_EXP_VALUE identifiers. There must be also the MDM repository with the RDS_REPO identifier that contains the MDM dictionary with the EXPORT identifier. This dictionary has an attribute with the ATTRIBUTE identifier that may have multiple values and is connected with another dictionary. Identifiers and field types of the OBJ_EXP table and of the EXPORT dictionary match. The OBJ_EXP table must also have a field of integer type with the KEY_EXP identifier. The OBJ_EXP_VALUE table must contain fields of integer type with the following identifiers: KEYFIELD, VALUEFIELD, ORDERFIELD.

Imports Prognoz.Platform.Interop.Db;
Imports Prognoz.Platform.Interop.Rds;

Public Shared Sub Main(Params: StartParams);
Var
    MB: IMetabase;
    MObj: IMetabaseObject;
    Dict: IRdsDictionary;
    Export: IRdsExportSchemas;
    SchemaExport: IRdsExportSchema;
    Attrs: IRdsAttributes;
    TableObj: IMetabaseObjectDescriptor;
    Table: ITable;
    SchemaExportAttr: IRdsExportSchemaAttribute;
    DictInst: IRdsDictionaryInstance;
Begin
    MB := Params.Metabase;
    MObj := MB.ItemByIdNamespace["EXPORT", MB.ItemById["RDS_REPO"].Key].Edit();
    Dict := MObj As IRdsDictionary;
    Attrs := Dict.Attributes;
    Export := Dict.ExportSchemas;
    SchemaExport := Export.Add();
    SchemaExport.Id := MB.GenerateId("Export1"0);
    SchemaExport.Name := Export scheme #1;
    SchemaExport.Mappings[Attrs.Key].FieldName := "Key";
    SchemaExport.Mappings[Attrs.Name].FieldName := "Name";
    SchemaExport.Mappings[Attrs.Order].FieldName := "Ord";
    SchemaExport.Mappings[Attrs.ParentKey].FieldName := "Parent_key";
    TableObj := MB.ItemById["OBJ_EXP"];
    Table := TableObj.Bind() As ITable;
    SchemaExport.TableObject := TableObj;
    SchemaExport.TableName := Table.NativeName;
    SchemaExportAttr := SchemaExport.Mappings[Attrs.FindById("ATTRIBUTE")];
//Binding attribute that has multiple values
    TableObj := MB.ItemById["OBJ_EXP_VALUE"];
    Table := TableObj.Bind() As ITable;
    SchemaExportAttr.DetailTableObject := TableObj;
    SchemaExportAttr.DetailTable := Table.NativeName;
    SchemaExportAttr.FieldName := "KEY_EXP";
    SchemaExportAttr.KeyField := "KEYFIELD";
    SchemaExportAttr.ValueField := "VALUEFIELD";
    SchemaExportAttr.OrderField := "ORDERFIELD";
    SchemaExportAttr.UpdateDetailTableMode := RdsUpdateDetailTableMode.expupddetUpdate;
    MObj.Save();
    DictInst := Dict.Open(Null);
    DictInst.ExportData(SchemaExport);
End Sub;

After executing the example a new export scheme is created in the MDM dictionary. Attribute values of the EXPORT dictionary are exported in same-name fields of the OBJ_EXP table. Multiple values of the ATTRIBUTE attribute are imported from the OBJ_EXP_VALUE table. Export will be executed. On export, values of the ATTRIBUTE attribute and records contained in the OBJ_EXP_VALUE table are associated. If a record that corresponds to the value of attribute is not found in the table, it is added there. If a record that does not correspond to any value of attribute is found in the table, it is deleted. If a record that corresponds with attribute value is found in the table, it is updated.

See also:

IRdsExportSchemaAttribute