IDatasetBatchUpdate.AddRecord

Syntax

AddRecord(FieldValues: Array);

Parameters

FieldValues is an array of new values of record. Values of elements in array should correspond to fields in a data source.

Description

The AddRecord method adds updated values of the record into the clipboard. Clipboard records in source are updated on calling the Commit method.

Example

Executing the example requires the table with the Table_1 identifier in repository. 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. On updating, value of the third field is changed taking into account values of previous two fields.

See also:

IDatasetBatchUpdate