Page 1 of 1

How to get the last sql query sent when error appear

Posted: Mon 08 Oct 2012 09:47
by Tony49
Hi,

I try to log the last sql query send to the database when an error appear. I looked at OnError event in TOraSession class but i don't know how to get the last sql query.

Re: How to get the last sql query sent when error appear

Posted: Mon 08 Oct 2012 13:13
by AlexP
Hello,

To retrieve the last SQL statement that has led to the error, you can use the Component property of the EDAError class, e.g. as follows:

Code: Select all

procedure TForm1.OraSession1Error(Sender: TObject; E: EDAError;
  var Fail: Boolean);
begin
  if E.Component is TCustomDADataSet then
    ShowMessage(TCustomDADataSet(E.Component).SQL.Text);
end;

Re: How to get the last sql query sent when error appear

Posted: Mon 08 Oct 2012 14:02
by Tony49
I had not seen 'Component' property. Thank's a lot.