Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-09

how to directly access field/record value of TBufDataSet?

12 messages · 5 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Dennis Poon

Since TBufDataSet is in-memory, to speed things up, how can I directly access the N'th record and M'th field's value as Variant?

At this stage, I only need to read the value, no to write it.

Also, how do I use the procedure LoadFromStream(AStream : TStream; Format: TDataPacketFormat = dfAny)?
Especially, I don't understand the TDataPacketFormat parameter.

Any help is greatly appreciated.

Dennis

Michael Van Canneyt
to Dennis Poon
Dennis Poon wrote
Since TBufDataSet is in-memory, to speed things up, how can I directly access the N'th record and M'th field's value as Variant?

Simply said: You cannot.

Michael.

LacaK
to Dennis Poon: Since TBufDataSet is in-memory, to speed things up, how can I directly access the N'th…

Dennis Poon wrote / napísal(a):

Also, how do I use the procedure LoadFromStream(AStream : TStream; Format: TDataPacketFormat = dfAny)? Especially, I don't understand the TDataPacketFormat parameter.

Using Format parameter you can signal to DatapacketReader in which format expect data (dfBinary, dfXML etc)
It is not required , when not set there is procedure which tests "incoming" data using RecognizeStream method and select those DatapacketReader, which is able handle "incoming" data. In other words each registered DataPacketReader is able say if is able handle data in stream or not.
(examines begining of stream and looks for own "format identification") -Laco.

Dennis Poon
to LacaK
Show quoted text 13 lines
> Also, how do I use the procedure LoadFromStream(AStream : > TStream; Format: TDataPacketFormat = dfAny)? > Especially, I don't understand the TDataPacketFormat parameter. Using Format parameter you can signal to DatapacketReader in which format expect data (dfBinary, dfXML etc) It is not required , when not set there is procedure which tests "incoming" data using RecognizeStream method and select those DatapacketReader, which is able handle "incoming" data. In other words each registered DataPacketReader is able say if is able handle data in stream or not. (examines begining of stream and looks for own "format identification") -Laco.

Let me clarify. How do I SaveToStream from another TDataset descendant and LoadFromStream in TBufdataSet?

I am trying to call SaveToStream from some Delphi TDataset Descendent to to be loaded by FPC's TBufdataSet.LoadFromStream. How should I do it?

Dennis

Michael Van Canneyt
to Dennis Poon: Since TBufDataSet is in-memory, to speed things up, how can I directly access the N'th…
Dennis Poon wrote 10 lines
Since TBufDataSet is in-memory, to speed things up, how can I directly access the N'th record and M'th field's value as Variant? > > Simply said: You cannot. > Can any one suggest an in-memory dataset in fpc/lazarus that allows direct access? Does TMemDataset allow it?

No. The architecture of TDataset does not allow this.

The buffer mechanism is quite complicated, and there are quite some layers to go through.

T(Mem)Dataset is not just an array of records. The records can be at wildly different locations, the values may or may not be computed. Blobs are stored entirely in different locations etc.

Michael.

LacaK
to Dennis Poon: Let me clarify. How do I SaveToStream from another TDataset descendant and…

Dennis Poon wrote / napísal(a):

Show quoted text 19 lines
>> Also, how do I use the procedure LoadFromStream(AStream : >> TStream; Format: TDataPacketFormat = dfAny)? >> Especially, I don't understand the TDataPacketFormat parameter. > Using Format parameter you can signal to DatapacketReader in which > format expect data (dfBinary, dfXML etc) > It is not required , when not set there is procedure which tests > "incoming" data using RecognizeStream method and select those > DatapacketReader, which is able handle "incoming" data. > In other words each registered DataPacketReader is able say if is > able handle data in stream or not. > (examines begining of stream and looks for own "format identification") > -Laco. > Let me clarify. How do I SaveToStream from another TDataset descendant and LoadFromStream in TBufdataSet? I am trying to call SaveToStream from some Delphi TDataset Descendent to to be loaded by FPC's TBufdataSet.LoadFromStream. How should I do it?

Can you try SaveToStream(..., dfXML) ?
Because Binary formats are not compatible between Delphi and FPC But in XML should be situation better ;-)
If you encounter any incompatibility please let us know ... (and attach XML saved by Delphi + if possible any test application) -Laco.

Dennis Poon
to Michael Van Canneyt: No. The architecture of TDataset does not allow this. The buffer mechanism is quite…
Michael Van Canneyt wrote 27 lines
On Tue, 1 Oct 2013, Dennis Poon wrote: > Since TBufDataSet is in-memory, to speed things up, how can I > directly access the N'th record and M'th field's value as Variant? >> >> Simply said: You cannot. >> > > Can any one suggest an in-memory dataset in fpc/lazarus that allows > direct access? > > Does TMemDataset allow it? No. The architecture of TDataset does not allow this. The buffer mechanism is quite complicated, and there are quite some layers to go through. T(Mem)Dataset is not just an array of records. The records can be at wildly different locations, the values may or may not be computed. Blobs are stored entirely in different locations etc. Michael.

That is too bad. I used to use TdxMemData from "DevExpress" and it allows such direct access.

The benefit is record can be accessed without CHANGING the current record pointer which will trigger updating of all linked DB controls (that could be time consuming or even confusing to the user).

Michael Van Canneyt
to Dennis Poon
Dennis Poon wrote 33 lines
Michael Van Canneyt wrote: > > > On Tue, 1 Oct 2013, Dennis Poon wrote: > >> Since TBufDataSet is in-memory, to speed things up, how can I directly >> access the N'th record and M'th field's value as Variant? >>> >>> Simply said: You cannot. >>> >> >> Can any one suggest an in-memory dataset in fpc/lazarus that allows direct >> access? >> >> Does TMemDataset allow it? > > No. The architecture of TDataset does not allow this. > > The buffer mechanism is quite complicated, and there are quite some layers > to go through. > > T(Mem)Dataset is not just an array of records. The records can be at wildly > different locations, > the values may or may not be computed. Blobs are stored entirely in > different locations etc. > > Michael. > That is too bad. I used to use TdxMemData from "DevExpress" and it allows such direct access.

Yes, it is possible to construct such a descendent. But in the general case it is not possible to provide this mechanism.

Maybe bufdataset can be extended to deliver this, but I would not hold my breath waiting for this.

I also used TdxMemData, but didn't see such mechanism. Of course, I never looked for it :)

The benefit is record can be accessed without CHANGING the current record pointer which will trigger updating of all linked DB controls (that could be time consuming or even confusing to the user).

I understand the benefits.

But if you need such access, then I think that TDataset is not for you.

Michael.