Asynchronous query executing & AfterFetch event

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
emb
Posts: 4
Joined: Tue 06 Apr 2010 11:30

Asynchronous query executing & AfterFetch event

Post by emb » Tue 06 Apr 2010 12:03

hi there!
i'm trying to use async query executing ... and have a problem with it.
i've made some simple sample :)
there are OraQuery1 with NonBlocking = true in it
and TForm1.OraQuery1AfterFetch procedure, subscribed on OraQuery1.AfterFetch event

an exception occurs at statement "showmessage(OraQuery1.FieldValues['S'])", cause OraQuery1.FieldValues['S'] is NULL !
BTW OraQuery1.RecordCount = 3 at same moment.
certainly, there are rows A,B,C, in the Grid1 later.

help me, plz, tell me what's going on?
3 records with nulls in dataset? but AfterFetch? and nulls transforming into A,B,C later? when? should i use another event?

Code: Select all

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, DB, DBAccess, Ora, MemDS, StdCtrls;

type
  TForm1 = class(TForm)
    OraSession1: TOraSession;
    OraQuery1: TOraQuery;
    OraDataSource1: TOraDataSource;
    Button1: TButton;
    DBGrid1: TDBGrid;
    procedure Button1Click(Sender: TObject);
    procedure OraQuery1AfterFetch(DataSet: TCustomDADataSet);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  if oraquery1.Active then
    oraquery1.Close;
  OraQuery1.SQL.Text :=
    'select ''A'' S from dual ' +
    'union select ''B'' S from dual ' +
    'union select ''C'' S from dual';
  OraQuery1.Open;
end;

procedure TForm1.OraQuery1AfterFetch(DataSet: TCustomDADataSet);
begin
  showmessage(OraQuery1.FieldValues['S']); // exception occurs
end;

end.

emb
Posts: 4
Joined: Tue 06 Apr 2010 11:30

Post by emb » Wed 07 Apr 2010 09:32

it works well :) with processmessages before it

Code: Select all

procedure TForm1.OraQuery1AfterFetch(DataSet: TCustomDADataSet); 
begin 
  application.ProcessMessages;
  showmessage(OraQuery1.FieldValues['S']); // no more exceptions
end; 

bork
Devart Team
Posts: 649
Joined: Fri 12 Mar 2010 07:55

Post by bork » Wed 07 Apr 2010 09:35

It is good to see that this problem has been solved.

emb
Posts: 4
Joined: Tue 06 Apr 2010 11:30

Post by emb » Wed 07 Apr 2010 10:46

this problem has not been solved.
the way - it's workaround.
it will be very nice, if this will be solved properly in ODAC new version.
i think so...

Post Reply