Clear
procedure Clear;
Example
procedure ClearOptionalComment(const Data: TvxClientDataSet);
begin
Data.Edit;
Data.FieldByName('Comment').Clear;
Data.Post;
end;
Usage
Clear assigns database null to a stored field in the current writable record buffer, subject to the field and dataset validation path.
- Call
Edit,AppendorInsertbefore clearing an ordinary stored field. - Test
IsNullafter the call when later logic distinguishes null from an empty string or zero. - Do not assume
Requiredrejects the null: Velox disables that base post check and gives the flag a persistence-specific meaning.
Additional Technical Info
Clear is declared by hidden ancestor TField and is used through a concrete field returned by a dataset such as TvxClientDataSet. It clears one pending field value; it does not remove a field, erase a dataset or by itself persist a database update.
Source-backed behaviour
The compiled modified TField.Clear checks whether the field's FieldKind is in its dataset's StoredFieldKinds. If so, it calls SetData with a nil value buffer. For a client dataset that reaches TCustomClientDataSet.SetFieldData, the dataset must be in a write mode, read-only and field validation rules are applied, DSBase verifies the field, the active record buffer is set to null and a field-change event is emitted. The pending record still needs Post; Velox client-dataset Post commits the client buffer, not necessarily the backing database.
TBlobField overrides this operation with its blob-stream implementation. Non-stored calculated or lookup fields can make the base call a no-op. A detached base field is not a useful script object: the implementation dereferences its dataset before it can issue the normal missing-dataset error.