Logging execution and results of query and script

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
FCS
Posts: 176
Joined: Sat 23 Feb 2013 18:46

Logging execution and results of query and script

Post by FCS » Fri 03 May 2013 09:34

Hello,

How to get log of execution a query or a script ?
For example, I want to know if all queries in the script are executed well.

Regards
Michal

stevel
Posts: 125
Joined: Tue 02 Nov 2010 19:01

Re: Logging execution and results of query and script

Post by stevel » Fri 03 May 2013 10:52

For UniScript, use OnError event to catch errors.

FCS
Posts: 176
Joined: Sat 23 Feb 2013 18:46

Re: Logging execution and results of query and script

Post by FCS » Fri 03 May 2013 11:05

Thanks,

There is a way to get information if a query went well.
The OnError event gets only error messages, I suppose.

There is a way to disable displaying error messages on screen, storing them only in a log file (created using onError event).

Regards
Michal

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

Re: Logging execution and results of query and script

Post by AlexP » Fri 10 May 2013 11:51

Hello,

To skip errors occurring during script execution in TUniScript, you should set the Action parameter to eaContinue in the onError event, in this case if an error occurs, it will be ignored and execution will continue.

FCS
Posts: 176
Joined: Sat 23 Feb 2013 18:46

Re: Logging execution and results of query and script

Post by FCS » Fri 10 May 2013 15:57

Hello,

Thanks for your reply.

Will be errors reported in the onError event when I set the "Action" parameter to eaContinue ?

I want to store event log to a log file when a script is executed. This way I must store success event and error events. When an error occurs I don't want the error message on the screen, I want it only in the log file. How to do this?

Regards
Michal

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

Re: Logging execution and results of query and script

Post by AlexP » Mon 13 May 2013 12:57

hello,

To log scripts execution, you can use the AfterExecute event, and for error logging - the onError event. The following sample demonstrates work with these events:

Code: Select all

var
  error: boolean;

..

procedure TForm1.UniScript1Error(Sender: TObject; E: Exception;
  SQL: String; var Action: TErrorAction);
begin
  //error logging
  error := True;
  Action := eaContinue;
end;

procedure TForm1.UniScript1AfterExecute(Sender: TObject; SQL: String);
begin
  if not Error then begin
    //successful script execution logging
    error := False;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  error := False;
  UniScript1.Execute;
end;
P.S. If you run the application from the IDE, and the Stop On Delphi Exception option is enabled, an error message will be shown in any way, independently on the Action parameter value; when running the application from *.exe - an error won't be shown ( Action = eaContinue)

FCS
Posts: 176
Joined: Sat 23 Feb 2013 18:46

Re: Logging execution and results of query and script

Post by FCS » Wed 15 May 2013 09:34

Hello,

Thanks for yor reply and advice.

Regards
Michal

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

Re: Logging execution and results of query and script

Post by AlexP » Wed 15 May 2013 12:18

Hello,

If you have any other questions, feel free to contact us

Post Reply