Sign in Join
FPDoc Onlineexperiment

TMemDataset class

In unit MemDs

Implements an in-memory dataset.

Declaration

pascal
TMemDataset = class(TDataSet)

Inheritance

  1. TMemDataset
  2. TDataSet
  3. TComponent
  4. TPersistent
  5. 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

FileModifiedpublicIndicates if the in-memory dataset has been modified.
FilterpublicFilter for the dataset.
FileNamepublishedFile name used to read or write field definitions and optional data.
FilteredpublishedIndicates if records in the dataset are filtered using OnFilterRecord.
ActivepublishedIndicates if the in-memory dataset is Active.
FieldDefspublishedField definitions for the in-memory dataset.
BeforeOpenpublishedEvent triggered before the dataset is opened.
AfterOpenpublishedEvent triggered after the dataset is opened.
BeforeClosepublishedEvent triggered before the dataset is closed.
AfterClosepublishedEvent triggered after the dataset is closed.
BeforeInsertpublishedEvent triggered before the dataset is put in insert mode.
AfterInsertpublishedEvent triggered after the dataset is put in insert mode.
BeforeEditpublishedEvent triggered before the dataset is put in edit mode.
AfterEditpublishedEvent triggered after the dataset is put in edit mode.
BeforePostpublishedEvent called before changes are posted to the underlying database.
AfterPostpublishedEvent called after changes have been posted to the underlying database.
BeforeCancelpublishedEvent triggered before a Cancel operation.
AfterCancelpublishedEvent triggered after a Cancel operation.
BeforeDeletepublishedEvent triggered before a Delete operation.
AfterDeletepublishedEvent triggered after a successful Delete operation.
BeforeScrollpublishedEvent triggered before the cursor changes position.
AfterScrollpublishedEvent triggered after the cursor has changed position.

Methods

AllocRecordBufferprotectedAllocates memory needed for a record buffer in the in-memory dataset.
FreeRecordBufferprotectedFrees memory allocated for the specified record buffer.
GetBookmarkDataprotectedGets Bookmark data from the specified record buffer.
GetBookmarkFlagprotectedGets BookmarkFlag data from the specified record buffer.
GetFieldDataprotectedGets data for the specified field from the active record buffer.
GetRecordprotectedGets a record buffer when navigating between rows in the in-memory dataset.
GetRecordSizeprotectedGets the value for the RecordSize property.
InternalAddRecordprotectedPerforms actions needed to add a record in the in-memory dataset.
InternalCloseprotectedPerforms actions needed when closing the in-memory dataset.
InternalDeleteprotectedPerforms actions needed to delete a record in the in-memory dataset.
InternalFirstprotectedPerforms actions needed to move to the first record in the in-memory dataset.
InternalGotoBookmarkprotectedPerforms actions need to find the record for the specified Bookmark.
InternalInitFieldDefsprotectedPerforms actions needed to initialize field definitions for the in-memory dataset.
InternalInitRecordprotectedPerforms actions needed to initialize a record in the in-memory dataset.
ClearCalcFieldsprotectedClears calculated field values.
InternalLastprotectedPerforms actions needed to move to the last record in the in-memory dataset.
InternalOpenprotectedPerforms actions needed to open the in-memory dataset.
InternalPostprotectedPerforms actions needed to post a record in the in-memory dataset.
InternalSetToRecordprotectedPerforms actions needed to move the dataset to the specified record.
IsCursorOpenprotectedIndicates if the cursor for the dataset is open.
SetBookmarkFlagprotectedSets the BookmarkFlag in the specified record buffer.
SetBookmarkDataprotectedSets the Bookmark data in the specified record buffer.
SetFieldDataprotectedSets the value for a field in the record buffer.
GetRecordCountprotectedGets the value for the RecordCount property.
SetRecNoprotectedSets the value for the RecNo property.
GetRecNoprotectedGets the value for the RecNo property.
SetFilterTextprotectedSilently drops value in the filter text.
RaiseErrorprotectedRaises an exception for an invalid operation in the in-memory dataset.
CheckMarkerprotectedChecks for the specified marker in the internal stream for the in-memory dataset.
WriteMarkerprotectedWrites the specified marker to the internal stream for the in-memory dataset.
ReadFieldDefsFromStreamprotectedReads field definitions from the specified stream.
SaveFieldDefsToStreamprotectedSaves field definitions to the specified stream.
LoadDataFromStreamprotectedLoads record data from the specified stream.
SaveDataToStreamprotectedSaves record data to the specified stream.
CreatepublicConstructor for the class instance.
DestroypublicDestructor for the class instance.
BookmarkValidpublicDetermines if the specified Bookmark is valid.
CompareBookmarkspublicGets the relative order for the specified Bookmarks.
CreateBlobStreampublicCreates a stream used to read or write Blob field data in the in-memory dataset.
LocatepublicLocates a record with the specified values in the in-memory dataset.
LookuppublicSearches for a record with the specified values, and returns a list of values.
CreateTablepublicCreates the internal storage for records in the in-memory dataset.
DataSizepublicSize of the internal TMemoryStream used in the in-memory dataset.
ClearpublicClears the content in the in-memory dataset.
SaveToFilepublicSaves field definitions and optional record data to the specified file name.
SaveToStreampublicSaves field definitions and optional record data to the specified stream.
LoadFromStreampublicLoads the content for the dataset from the specified stream.
LoadFromFilepublicLoads the content for the dataset from the specified file name.
CopyFromDatasetpublicLoads field definitions and optional data from the specified TDataset.

Events

OnDeleteErrorpublishedEvent triggered when a delete operation fails.
OnEditErrorpublishedEvent triggered when an edit operation fails.
OnNewRecordpublishedEvent triggered when a new record is created.
OnPostErrorpublishedEvent triggered when a post operation fails.
OnFilterRecordpublishedEvent 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.