Asynchronous query executing & AfterFetch event
Posted: 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?
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.