TMemDataset class
Implements an in-memory dataset.
Declaration
TMemDataset = class(TDataSet)Inheritance
- TMemDataset
- TDataSet
- TComponent
- TPersistent
- TObject
Description
TMemDataset is a TDataset descendant which implements an in-memory dataset. TMemDataset is a performant, single user dataset for non-mission critical use cases that do not require transactions. All record and field processing is done in memory; no data is read from or written to disk unless explicitly requested.
TMemDataset implements common facilities defined in the TDataset ancestor class. This includes using the FieldDefs property to define the structure for the dataset. Most (but not all) field types are supported in TMemDataset, including:
- ftString
- ftGuid
- ftFixedChar
- ftBoolean
- ftCurrency
- ftFloat
- ftBCD
- ftLargeInt
- ftSmallInt
- ftWord
- ftInteger
- ftAutoInc (behave like ftInteger i.e. no auto-increment functionality)
- ftDateTime
- ftDate
- ftTime
- ftFmtBCD
- ftWideString
- ftFixedWideChar
- ftBytes
- ftVarBytes
- ftBlob
- ftMemo
- ftWideMemo
TMemDataset implements common data manipulation methods such as: Append, AppendRecord, Insert, InsertRecord, Delete, Clear, and Refresh. TMemDataset implements Bookmarks and common navigation methods like: First, Next, Prior, Last, Locate, BOF, and EOF. Methods are provided that allow loading and saving both structure and data from a file, a stream, or another TDataset descendent.
TMemDataset provides methods to filter records, but they are implemented in a different manner than in TDataset. The Filter property is ignored; use the OnFilterRecord method and the Filtered property for this functionality.
One notable missing feature is Indexes. Index definitions are not implemented in TMemDataset.
TMemDataset uses ideas taken from the THKMemTab component by Harri Kasulke. (Hamburg/Germany)
See also
Properties
FileModified | public | Indicates if the in-memory dataset has been modified. |
Filter | public | Filter for the dataset. |
FileName | published | File name used to read or write field definitions and optional data. |
Filtered | published | Indicates if records in the dataset are filtered using OnFilterRecord. |
Active | published | Indicates if the in-memory dataset is Active. |
FieldDefs | published | Field definitions for the in-memory dataset. |
BeforeOpen | published | Event triggered before the dataset is opened. |
AfterOpen | published | Event triggered after the dataset is opened. |
BeforeClose | published | Event triggered before the dataset is closed. |
AfterClose | published | Event triggered after the dataset is closed. |
BeforeInsert | published | Event triggered before the dataset is put in insert mode. |
AfterInsert | published | Event triggered after the dataset is put in insert mode. |
BeforeEdit | published | Event triggered before the dataset is put in edit mode. |
AfterEdit | published | Event triggered after the dataset is put in edit mode. |
BeforePost | published | Event called before changes are posted to the underlying database. |
AfterPost | published | Event called after changes have been posted to the underlying database. |
BeforeCancel | published | Event triggered before a Cancel operation. |
AfterCancel | published | Event triggered after a Cancel operation. |
BeforeDelete | published | Event triggered before a Delete operation. |
AfterDelete | published | Event triggered after a successful Delete operation. |
BeforeScroll | published | Event triggered before the cursor changes position. |
AfterScroll | published | Event triggered after the cursor has changed position. |
Methods
AllocRecordBuffer | protected | Allocates memory needed for a record buffer in the in-memory dataset. |
FreeRecordBuffer | protected | Frees memory allocated for the specified record buffer. |
GetBookmarkData | protected | Gets Bookmark data from the specified record buffer. |
GetBookmarkFlag | protected | Gets BookmarkFlag data from the specified record buffer. |
GetFieldData | protected | Gets data for the specified field from the active record buffer. |
GetRecord | protected | Gets a record buffer when navigating between rows in the in-memory dataset. |
GetRecordSize | protected | Gets the value for the RecordSize property. |
InternalAddRecord | protected | Performs actions needed to add a record in the in-memory dataset. |
InternalClose | protected | Performs actions needed when closing the in-memory dataset. |
InternalDelete | protected | Performs actions needed to delete a record in the in-memory dataset. |
InternalFirst | protected | Performs actions needed to move to the first record in the in-memory dataset. |
InternalGotoBookmark | protected | Performs actions need to find the record for the specified Bookmark. |
InternalInitFieldDefs | protected | Performs actions needed to initialize field definitions for the in-memory dataset. |
InternalInitRecord | protected | Performs actions needed to initialize a record in the in-memory dataset. |
ClearCalcFields | protected | Clears calculated field values. |
InternalLast | protected | Performs actions needed to move to the last record in the in-memory dataset. |
InternalOpen | protected | Performs actions needed to open the in-memory dataset. |
InternalPost | protected | Performs actions needed to post a record in the in-memory dataset. |
InternalSetToRecord | protected | Performs actions needed to move the dataset to the specified record. |
IsCursorOpen | protected | Indicates if the cursor for the dataset is open. |
SetBookmarkFlag | protected | Sets the BookmarkFlag in the specified record buffer. |
SetBookmarkData | protected | Sets the Bookmark data in the specified record buffer. |
SetFieldData | protected | Sets the value for a field in the record buffer. |
GetRecordCount | protected | Gets the value for the RecordCount property. |
SetRecNo | protected | Sets the value for the RecNo property. |
GetRecNo | protected | Gets the value for the RecNo property. |
SetFilterText | protected | Silently drops value in the filter text. |
RaiseError | protected | Raises an exception for an invalid operation in the in-memory dataset. |
CheckMarker | protected | Checks for the specified marker in the internal stream for the in-memory dataset. |
WriteMarker | protected | Writes the specified marker to the internal stream for the in-memory dataset. |
ReadFieldDefsFromStream | protected | Reads field definitions from the specified stream. |
SaveFieldDefsToStream | protected | Saves field definitions to the specified stream. |
LoadDataFromStream | protected | Loads record data from the specified stream. |
SaveDataToStream | protected | Saves record data to the specified stream. |
Create | public | Constructor for the class instance. |
Destroy | public | Destructor for the class instance. |
BookmarkValid | public | Determines if the specified Bookmark is valid. |
CompareBookmarks | public | Gets the relative order for the specified Bookmarks. |
CreateBlobStream | public | Creates a stream used to read or write Blob field data in the in-memory dataset. |
Locate | public | Locates a record with the specified values in the in-memory dataset. |
Lookup | public | Searches for a record with the specified values, and returns a list of values. |
CreateTable | public | Creates the internal storage for records in the in-memory dataset. |
DataSize | public | Size of the internal TMemoryStream used in the in-memory dataset. |
Clear | public | Clears the content in the in-memory dataset. |
SaveToFile | public | Saves field definitions and optional record data to the specified file name. |
SaveToStream | public | Saves field definitions and optional record data to the specified stream. |
LoadFromStream | public | Loads the content for the dataset from the specified stream. |
LoadFromFile | public | Loads the content for the dataset from the specified file name. |
CopyFromDataset | public | Loads field definitions and optional data from the specified TDataset. |
Events
OnDeleteError | published | Event triggered when a delete operation fails. |
OnEditError | published | Event triggered when an edit operation fails. |
OnNewRecord | published | Event triggered when a new record is created. |
OnPostError | published | Event triggered when a post operation fails. |
OnFilterRecord | published | Event handler signalled to include or exclude records in the in-memory dataset. |
Inherited
From TDataSet (187)
ActivateBuffers ActiveBuffer ActiveRecord AfterRefresh Append AppendRecord AutoCalcFields BeforeRefresh BindFields BlobFieldCount BlockReadNext BlockReadSize BOF Bookmark BookmarkAvailable BookmarkSize BufferCount Buffers CalcBuffer CalcFieldsSize CalculateFields Cancel CanModify CheckActive CheckBiDirectional CheckBrowseMode CheckInactive ClearBuffers ClearFields Close CloseBlob CloseCursor Constraints ControlsDisabled CreateFields CurrentRecord CursorPosChanged DataConvert DataEvent DataSource DefaultFields Delete DestroyFields DisableControls DoAfterCancel DoAfterClose DoAfterDelete DoAfterEdit DoAfterInsert DoAfterOpen DoAfterPost DoAfterRefresh DoAfterScroll DoBeforeCancel DoBeforeClose DoBeforeDelete DoBeforeEdit DoBeforeInsert DoBeforeOpen DoBeforePost DoBeforeRefresh DoBeforeScroll DoOnCalcFields DoOnNewRecord Edit EnableControls EOF FieldByName FieldByNumber FieldCount FieldDefsClass Fields FieldsClass FieldValues FilterOptions FindField FindFirst FindLast FindNext FindPrior FindRecord First Found FreeBookmark FreeFieldBuffers GetBookmark GetBookmarkStr GetCalcFields GetCanModify GetChildren GetCurrentRecord GetDataSource GetDefaultBufferCount GetFieldClass GetfieldCount GetFieldList GetFieldNames GetFieldValues GetIndexDefs GetIsIndexField GetNextRecord GetNextRecords GetPriorRecord GetPriorRecords GotoBookmark InitFieldDefs InitFieldDefsFromFields InitRecord Insert InsertRecord InternalCalcFields InternalCancel InternalEdit InternalHandleException InternalInsert InternalRefresh IsEmpty IsLinkedTo IsSequenced IsUniDirectional Last Loaded Modified MoveBy MyDataSourceCount MyDataSources Next OnCalcFields Open OpenCursor OpenCursorcomplete Post Prior PSEndTransaction PSExecute PSExecuteStatement PSGetAttributes PSGetCommandText PSGetCommandType PSGetDefaultOrder PSGetIndexDefs PSGetKeyFields PSGetParams PSGetQuoteChar PSGetTableName PSGetUpdateException PSInTransaction PSIsSQLBased PSIsSQLSupported PSReset PSSetCommandText PSSetParams PSStartTransaction PSUpdateRecord RecalcBufListSize RecNo RecordCount RecordSize Refresh RefreshInternalCalcFields RestoreState Resync SetActive SetBookmarkStr SetBufListSize SetChildOrder SetCurrentRecord SetDefaultFields SetFields SetFieldValues SetFiltered SetFilterOptions SetFound SetModified SetName SetOnFilterRecord SetState SetTempState SetUniDirectional SparseArrays State TempBuffer Translate UpdateCursorPos UpdateIndexDefs UpdateRecord UpdateStatus
From TComponent (70)
_AddRef _Release BeforeDestruction CanObserve ChangeName ComObject ComponentCount ComponentIndex Components ComponentState ComponentStyle DefineProperties DesignInfo DestroyComponents Destroying ExecuteAction FindComponent FreeNotification FreeOnRelease GetChildOwner GetChildParent GetDeltaStreams GetEnumerator GetIDsOfNames GetNamePath GetObservers GetOwner GetParentComponent GetTypeInfo GetTypeInfoCount HasParent iicrGetComponent InsertComponent Invoke IsImplementorOf Loading Name Notification ObserverAdded Observers OnGetDeltaStreams Owner PaletteCreated QueryInterface ReadDeltaState ReadDeltaStream ReadState ReferenceInterface RemoveComponent RemoveFreeNotification RemoveFreeNotifications SafeCallException SetAncestor SetDesigning SetDesignInstance SetInline SetParentComponent SetSubComponent Tag ToString TToStringNameMode UpdateAction Updated UpdateRegistry Updating ValidateContainer ValidateInsert ValidateRename VCLComObject WriteState
From TPersistent (5)
Assign AssignTo FPOAttachObserver FPODetachObserver FPONotifyObservers
From TObject (37)
AfterConstruction CheckDisposed ClassInfo ClassName ClassNameIs ClassParent ClassType CleanupInstance DefaultHandler DefaultHandlerStr Dispatch DispatchStr Disposed DisposeOf Equals FieldAddress Free FreeInstance GetDisposed GetHashCode GetInterface GetInterfaceByStr GetInterfaceEntry GetInterfaceEntryByStr GetInterfaceTable GetInterfaceWeak GetLastCastErrorInfo InheritsFrom InitInstance InstanceSize MethodAddress MethodName newinstance QualifiedClassName StringMessageTable SystemHasExtendedRTTI UnitName
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
