[lazarus] ... TDBGrid interbase problems ...
Michael.VanCanneyt at Wisa.be
Michael.VanCanneyt at Wisa.be
Sun Jun 1 06:32:29 EDT 2003
On Sat, 31 May 2003, [iso-8859-1] Jesus Reyes wrote:
>
> Sorry answering after so long time :), and sorry too because i can't
> link to the original message thread:
>
> >
> > Though, I also like the idea of displaying only the data when
> needed. But
> I
> > think we need help from you guys as to understanding why is it that
> TDBGrid
> > cannot scroll backwards specially for tables with more 10
> records(at least
> for
> > Firebird. )
> >
> > Regards,
> >
> > Yoyong
> >
>
> Michael appointed after that message that 10 records is probably
> related to the
>
> Const
> DefaultBufferCount = 10;
>
> defined in dataset.inc
>
> this is right!. Now, TDBgrid actually can do backward/forward scroll.
> what happen is that TIBQuery "Implementation" explicitly deny this,
> take a look at the following code in TIBQuery.GetRecord:
>
> ...
> if FIsEOF then
> Result := grEOF
> else
> begin
> Result := grOK;
> case GetMode of
> ....
> end;
> if Result = grOK then
> begin
> with PIBBookmark(Buffer + FRecordSize)^ do
> begin
> BookmarkData := FCurrentRecord;
> BookmarkFlag := bfCurrent;
> end;
> end
> else if (Result = grError) then
> DatabaseError('No record');
> end;
>
> once TIbQuery reach EOF it can't fetch more records, you have a
> number a buffers allocated in TDataset (10) beyond this limit
> TIBQuery can't fetch previous records, so if you reach record 23, you
> will not be able to backscroll before record 13
>
> TDataset buffer system is a cycled one and in this situation you can
> see the buffers content cycling in the grid, this could be seen as an
> error but I don't think it is so.
>
> What can we do to get it working as it is, I'm affraid raising
> artificially the TDataset.Buffercount by means of DbGrid's
> FDatalink.Buffercount as Yoyong already done, until TIBQuery
> implementation gets updated, maybe
> FDataLink.BufferCount:=FDataLink.DataSet.RecordCount And updating on
> trying to get the next record?
I don't think this is a good idea. It will blow up your program's memory and
be very low, because at each 'Next' all buffers will be reallocated,
re-updating the entire grid twice etc. This is not a good solution.
Interbase itself allows only forward scrolling in a result set. This means
The TIBQuery class should allocate result buffers by itself as it goes
along, keeping all fetched data in memory.
This problem will occur not only in Interbase, but also in other major
database engines (mysql is a notable exception) , so it may be a good
idea to provide a separate class for this.
Michael.
More information about the Lazarus
mailing list