Page 1 of 1

How to know if executeQuery gave error?

Posted: Thu Jun 13, 2019 7:52 pm
by marcosfpa
How to know if executeQuery gave error?

For example: I need to put a control where when a executeQuery ($ sql, $ db) can not connect to the database I can somehow store a warning in a variable. How to make?

Re: How to know if executeQuery gave error?

Posted: Fri Jun 14, 2019 6:54 pm
by amosbatto
You can create another trigger with this code:
Code: Select all
@@errorMessage = @@__ERROR__;
Set this trigger to fire after your other trigger which executes executeQuery().

If you want to display this in a Dynaform, then create a text field in Dynaform associated with the "errorMessage" variable.

Re: How to know if executeQuery gave error?

Posted: Sat Jun 15, 2019 8:19 am
by marcosfpa
This way it does not answer because I execute the trigger in a script task, that is, without form ... Is there any output ??

Re: How to know if executeQuery gave error?

Posted: Mon Jun 17, 2019 6:17 pm
by amosbatto
I don't have time to test this, but try this:
Code: Select all
if (!empty(@@__ERROR__)) {
   throw new Exception(@@__ERROR__);
} 
If that doesn't work, then try this:
Code: Select all
if (!empty(@@__ERROR__)) {
   $g = new G();
   $g->SendMessageText(@@__ERROR__, "ERROR");
   unset(@@__ERROR);
}
If neither work, then the only solution is to display the error in a later Dynaform.