Skip to main content

Insert

procedure Insert;

Example

procedure InsertRecord(const Data: TvxClientDataSet);
begin
Data.Insert;
try
Data.FieldByName('Code').AsString := 'A100';
Data.Post;
except
Data.Cancel;
raise;
end;
end;

Usage

Call Insert on an active, editable dataset when you want to start a new record at or near the current cursor position. Use Append instead when the new record should be added at the logical end. If the dataset is sorted or indexed, that ordering can reposition the record, so do not use insertion position as a business sequence number.

After Insert, assign the field values and call Post to accept the pending record or Cancel to abandon it. The operation changes the dataset buffer and does not by itself save anything to an external database.

Additional Technical Info

Insert is declared by hidden ancestor TDataSet and is normally used through a visible descendant such as TvxClientDataSet. Concrete datasets decide the final physical/order placement.

Source-backed behaviour

After common browse/modify/events checks, the base saves the current bookmark, shifts its record buffer, initializes a new record, marks it at BOF when appropriate or copies the prior bookmark, invokes descendant InternalInsert, then enters dsInsert, runs new-record and insert/scroll notifications.

The row remains pending until Post. For a sorted/indexed client dataset, logical order is index-driven; the requested insertion location is not a durable row order contract.

Operational guidance

  • Do not use insert position as a business sequence key.
  • Assign required fields and Post, or Cancel on failure.
  • The operation can auto-resolve a previous edit through browse mode.
  • It does not begin a server transaction.

Append starts at the logical end. InsertRecord supplies positional values and completes immediately.

Official RTL references

Created 2026-07-15