IDatasetBatchUpdate.KeyFieldNames

Syntax

KeyFieldNames: String;

Description

The KeyFieldNames property determines the list of key fields, by values of which the search of updated records is performed.

Comments

Fields in the list are separated with semicolon. Required values are taken from clipboard.

Example

Executing the example requires that the repository contains a table with the Table_1 identifier. The table contains three fields with integer values.

Sub Main;

Var

MB: IMetabase;

Dsi: IDatasetInstance;

Fields: IDatasetInstanceFields;

Dbu: IDatasetBatchUpdate;

Vals: Array[0..2] Of Variant;

i: Integer;

Begin

MB := MetabaseClass.Active;

Dsi := MB.ItemById("Table_1").Open(Null) As IDatasetInstance;

Fields := Dsi.Fields;

Dbu := Dsi.CreateBatchUpdate;

Dbu.BatchCommand := DatasetBatchCommand.Update;

Dbu.KeyFieldNames := Fields.Item(0).Id;

Dbu.BeginUpdate;

While Not Dsi.Eof Do

i := Fields.Item(0).Value As Integer;

If i > 100 Then

Vals[0] := i;

Vals[1] := Fields.Item(1).Value;

Vals[2] := (i + (Fields.Item(1).Value As Integer)) * 100;

Dbu.AddRecord(Vals);

End If;

Dsi.Next;

End While;

Dbu.Commit;

End Sub Main;

After executing the example, records, which values of the first field are more than 100, are updated in the table. Existing records are searched by values of the first field. On updating, value of the third field is changed taking into account values of previous two fields.

See also:

IDatasetBatchUpdate