Page 1 of 1

Logging execution and results of query and script

Posted: Fri 03 May 2013 09:34
by FCS
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

Re: Logging execution and results of query and script

Posted: Fri 03 May 2013 10:52
by stevel
For UniScript, use OnError event to catch errors.

Re: Logging execution and results of query and script

Posted: Fri 03 May 2013 11:05
by FCS
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

Re: Logging execution and results of query and script

Posted: Fri 10 May 2013 11:51
by AlexP
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.

Re: Logging execution and results of query and script

Posted: Fri 10 May 2013 15:57
by FCS
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

Re: Logging execution and results of query and script

Posted: Mon 13 May 2013 12:57
by AlexP
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)

Re: Logging execution and results of query and script

Posted: Wed 15 May 2013 09:34
by FCS
Hello,

Thanks for yor reply and advice.

Regards
Michal

Re: Logging execution and results of query and script

Posted: Wed 15 May 2013 12:18
by AlexP
Hello,

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