How to get the last sql query sent when error appear

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Tony49
Posts: 21
Joined: Mon 26 Jan 2009 17:10

How to get the last sql query sent when error appear

Post by Tony49 » Mon 08 Oct 2012 09:47

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.

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

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

Post by AlexP » Mon 08 Oct 2012 13:13

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;

Tony49
Posts: 21
Joined: Mon 26 Jan 2009 17:10

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

Post by Tony49 » Mon 08 Oct 2012 14:02

I had not seen 'Component' property. Thank's a lot.

Post Reply