PrimaryKey: String;
PrimaryKey: String;
The PrimaryKey property determines the list of fields/attributes being the primary key.
The specified fields are used to check whether the data of the consumer table differs from the provider table data and to perform the specified update operation (for instance, the adding of the records that are not found by the primary key). The fields in the list must be specified in the upper case and be separated by the ";". The data updating mode is determined by the BatchMode property.
Executing the example requires that the repository contains a table with the T_Data identifier. The table contains the UNIQUENAME field containing unique data.
Add a link to the Metabase system assembly.
Sub UserProc;
Var
MB: IMetabase;
MBDesc: IMetabaseObjectDescriptor;
MUpdate: IMetabaseUpdate;
ObjNode: IMetabaseUpdateDataObjectNode;
Begin
MB := MetabaseClass.Active;
MBDesc := MB.ItemById("T_Data");
MUpdate := MB.CreateUpdate;
MUpdate.BoundType := MetabaseObjectUpdateBoundType.ById;
MUpdate.AlterType(MetabaseObjectClass.KE_CLASS_TABLE) := MetabaseObjectAlterType.Recreate;
MUpdate.Description := "Update for table";
ObjNode := MUpdate.RootFolder.Add(MetabaseUpdateNodeType.DataObject) As IMetabaseUpdateDataObjectNode;
//Determine updated object
ObjNode.Object := MBDesc;
//Update parameters
ObjNode.Label := MBDesc.Id;
ObjNode.UpdatePart := MetabaseObjectUpdatePart.DataMetadata;
ObjNode.BoundType := MetabaseObjectUpdateBoundType.ByKey;
ObjNode.Method := MetabaseUpdateMethod.All;
ObjNode.BatchMode := ObjectUpdateDataBatchMode.UpdateInsert;
ObjNode.PrimaryKey := "UNIQUENAME";
//Save update
MUpdate.SaveToFileNF("C:\Update.pefx");
End Sub UserProc;
On executing the example update file will be created. The update will include the specified table.
The requirements and result of the Fore.NET Example execution match with those in the Fore Example.
Add a link to the ForeSystem system assembly.
Imports Prognoz.Platform.Interop.Metabase;
Imports Prognoz.Platform.Interop.ForeSystem;
…
Public Shared Sub Main(Params: StartParams);
Var
MB: IMetabase;
MBDesc: IMetabaseObjectDescriptor;
MUpdate: IMetabaseUpdate;
ObjNode: IMetabaseUpdateDataObjectNode;
Begin
MB := Params.Metabase;
MBDesc := MB.ItemById["T_Data"];
MUpdate := MB.CreateUpdate();
MUpdate.BoundType := MetabaseObjectUpdateBoundType.moubtById;
MUpdate.AlterType[MetabaseObjectClass.KE_CLASS_TABLE As Integer] := MetabaseObjectAlterType.meobaltyRecreate;
MUpdate.Description := "Update for table";
ObjNode := MUpdate.RootFolder.Add(MetabaseUpdateNodeType.untDataObject) As IMetabaseUpdateDataObjectNode;
//Determine updated object
ObjNode.Object := MBDesc;
//Update parameters
ObjNode.Label := MBDesc.Id;
ObjNode.UpdatePart := MetabaseObjectUpdatePart.moupDataMetadata;
ObjNode.BoundType := MetabaseObjectUpdateBoundType.moubtByKey;
ObjNode.Method := MetabaseUpdateMethod.mumAll;
ObjNode.BatchMode := ObjectUpdateDataBatchMode.obupdabamoUpdateInsert;
ObjNode.PrimaryKey := "UNIQUENAME";
//Save update
MUpdate.SaveToFileNF("C:\\Update.pefx");
End Sub;
See also: