Declaration¶
Source position: bufdataset.pas line 462
type
TCustomBufDataset = class(TDBDataset)
public
constructor Create;
function GetFieldData(Field: TField; Buffer: Pointer;
NativeFormat: Boolean) : Boolean;
function GetFieldData(Field: TField; Buffer: Pointer) : Boolean;
procedure SetFieldData(Field: TField; Buffer: Pointer;
NativeFormat: Boolean);
procedure SetFieldData(Field: TField; Buffer: Pointer);
procedure ApplyUpdates; overload;
procedure ApplyUpdates(MaxErrors: Integer); overload;
procedure MergeChangeLog;
procedure RevertRecord;
procedure CancelUpdates;
destructor Destroy;
function Locate : Boolean;
function Lookup : Variant;
function UpdateStatus : TUpdateStatus;
function CreateBlobStream : TStream;
procedure AddIndex;
procedure ClearIndexes;
procedure SetDatasetPacket;
procedure GetDatasetPacket;
procedure LoadFromStream;
procedure SaveToStream;
procedure LoadFromFile;
procedure SaveToFile;
procedure CreateDataset;
procedure Clear;
function BookmarkValid : Boolean;
function CompareBookmarks : LongInt;
procedure CopyFromDataset;
property ChangeCount: Integer; {r}
property MaxIndexesCount: Integer; {rwd}
property ReadOnly: Boolean; {rwd}
property ManualMergeChangeLog: Boolean; {rwd}
published
property FileName: TFileName; {rw}
property PacketRecords: Integer; {rwd}
property OnUpdateError: TResolverErrorEvent; {rw}
property IndexDefs: TIndexDefs; {r}
property IndexName: string; {rw}
property IndexFieldNames: string; {rw}
property UniDirectional: Boolean; {rwd}
end;
Inheritance¶
Description¶
TCustomBufDataset is a TDBDataset descendant that implements the ancestor class for a database-aware buffered dataset. TCustomBufDataset is an in-memory dataset that can be used as a local stand-alone dataset, or it can be used as a local buffer for updates applied to a remote dataset. TCustomBufDataset implements many features similar to those in TClientDataset in Delphi. However, it is not meant to be code or function compatible with TClientDataset. It is designed to provide management of the buffers used to access record data, and is used as the ancestor for classes like TSQLQuery and TRESTBufDataset.
As a TDBDataset descendant, it offers access to many of the database features supported in the FCL DB package. As a TDataset descendant, it also offers access to familiar navigation and data handling methods in the ancestor class. TCustomBufDataset has features that allow local storage and retrieval of field definitions and record data. In addition, facilities are provided that allow local indexing of record data in the dataset. There is a comprehensive parser/expression evaluator available that allows complete support for Filters in the dataset.
Do not create instances of TCustomBufDataset. Use the TBufDataset descendant instead.
Additional information about using TBufDataset can be found on the Lazarus Wiki at: How to write in-memory database applications in Lazarus/FPC (TBufDataset).
Properties¶
| Member | Visibility | Description |
|---|---|---|
| ChangeCount read only | public | Number of pending changes for the dataset. |
| FileName | published | File name on the local file system used to load or store the dataset. |
| IndexDefs read only | published | Index definitions for the dataset. |
| IndexFieldNames | published | Field names included in the custom index. |
| IndexName | published | Name of the selected index for the dataset. |
| ManualMergeChangeLog | public | Indicates if the update change log can be manually merged. |
| MaxIndexesCount | public | Maximum number of indexes available in the dataset. |
| PacketRecords | published | Number of records allowed in a data packet handled by the packet reader. |
| ReadOnly | public | Indicates if records can be added, deleted, or modified in the dataset. |
| UniDirectional | published | Indicates if the dataset is for uni-directional navigation only. |
Methods¶
| Member | Visibility | Description |
|---|---|---|
| AddIndex | public | Adds an index definition to the dataset. |
| ApplyUpdates | public | Applies pending updates to the dataset. |
| BookmarkValid | public | Determines if the specified Bookmark is valid for the dataset. |
| CancelUpdates | public | Cancels pending updates in the dataset. |
| Clear | public | Clears the content in the dataset. |
| ClearIndexes | public | Clears index storage in the dataset. |
| CompareBookmarks | public | Gets the relative sort order for the specified Bookmarks. |
| CopyFromDataset | public | Loads field definitions and optional data from another dataset. |
| Create | public | Constructor for the class instance. |
| CreateBlobStream | public | Create blob stream. |
| CreateDataset | public | Creates the dataset using its field definitions or bound fields. |
| Destroy | public | Free a TDataset instance. |
| GetDatasetPacket | public | Builds a data packet representing the content in the buffered dataset. |
| GetFieldData | public | Get the data for a field. |
| LoadFromFile | public | Loads the dataset from the specified file using the given format. |
| LoadFromStream | public | Loads the dataset from the specified stream using the given data format. |
| Locate | public | Locate a record based on some key values. |
| Lookup | public | Search for a record and return matching values. |
| MergeChangeLog | public | Frees update buffers and Blob update buffer allocated for the dataset. |
| RevertRecord | public | Reverts the current record to its original (un-edited) values. |
| SaveToFile | public | Saves the dataset to the specified file using the given data format. |
| SaveToStream | public | Saves the dataset to the specified stream using the given data format. |
| SetDatasetPacket | public | Retrieves and applies the data packet with the content for the dataset. |
| SetFieldData | public | Store the data for a field. |
| UpdateStatus | public | Get the update status for the current record. |
Events¶
| Member | Visibility | Description |
|---|---|---|
| OnUpdateError | published | Event handler signalled when an error occurs while updating records. |
See also¶
| Name | Description |
|---|---|
| TBufDataset | Implements a database-aware buffered dataset. |
| TDBDataset | Dataset connected to a database. |
| TDataset | Base class for records-based data-access. |