Get all newly fetched records on fetch

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
kiiver
Posts: 5
Joined: Tue 05 Apr 2011 11:23

Get all newly fetched records on fetch

Post by kiiver » Fri 13 May 2011 09:08

I have some trouble to implement such logic that after TOraStoredProc fetches new rows, all that new data is also saved elsewhere instead only showing in dbgrid.
In other words, when scrolling down on dbgrid then after every 25 (FetchRows count) rows new data is fetched but those rows must be available for another processing.

I cannot find procedure like OnFetch or AfterFetch, so how to detect fetch event and then get content?

Then after, do i need to scroll all rows after every fetch to get last fetched row or is there some smarter possibility like getting that data simultaneously when actually fetching? One thought is to somehow divide datasource to two components - dbgrid and some other. Dbgrid should be primary and second component should only mirror those rows but not fetch or change active row on dbgrid when doing its own processing.

Also the process should not interfere dbgrid navigation and with minimal performance hit as the fetched row count can get over 1000.

Maybe i overlooked something but hope to get some ideas..

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Fri 13 May 2011 10:48

Hello,

There is no AfterFetch event in the TOraStoredProc class, but it is available in its ancestor. That's why you can create a TOraStoredProc successor and move this event to the Public section.

Here is a small sample:

Code: Select all

  TMyOraStoredProc= class(TOraStoredProc)
  public
    property AfterFetch;
  end;


....
MyOraStoredProc := TMyOraStoredProc.Create(nil);
MyOraStoredProc.Session := OraSession1;
MyOraStoredProc.AfterFetch := MyOraStoredProcAfterFetch;
MyOraStoredProc.StoredProcName := 'get_cur';
OraDataSource1.DataSet:= MyOraStoredProc;
MyOraStoredProc.Open;
...

procedure TForm1.MyOraStoredProcAfterFetch(DataSet: TCustomDADataSet);
begin
ShowMessage('Fetched');
end;
We will consider possibility to add this event to the ToraStoredProc in one of the next versions.

kiiver
Posts: 5
Joined: Tue 05 Apr 2011 11:23

Post by kiiver » Fri 13 May 2011 15:02

Thanks, got it working.

With newly fetched rows i did the usual DataSet stuff like
GetBookmark;
DisableControls;
loop Next;
...
GotoBookmark;
EnableControls;

and no performance hit whatsoever:)

Post Reply