Page 1 of 1

Asynchronous query executing & AfterFetch event

Posted: Tue 06 Apr 2010 12:03
by emb
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.

Posted: Wed 07 Apr 2010 09:32
by emb
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; 

Posted: Wed 07 Apr 2010 09:35
by bork
It is good to see that this problem has been solved.

Posted: Wed 07 Apr 2010 10:46
by emb
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...