Wissensdatenbank

Error in XML Script causes Space Manager to crash or hang

Hint Ref: 020906080035
Hint Date: 08/06/2009

Hint Details:

PROBLEM:

 

If an error occurs within an XML job then often an error message is displayed followed by a succession of Access Violations.  Clearing the Access Violations often either crashes Space Manager or causes it to hang.

SOLUTION:

One solution has always been to run the XML Job Modally under the XML Jobs option. But this is clearly not an option if the job needs to be run from a report menu.

The issue appears to be that the Delphi error handling, when dealing with errors from within an XML job, leaves something to be desired.

The solution would appear to be to handle the error from WINTHIN the XML job itself.

The mechanism to handle errors is to enclose the section of the script in which the error might be generated with a <Block> and </Block> statement.  After an error, control jumps to the next segment of script contained within the <Catch> and </Catch> statement.

NOTE: It is very important to remember that it is up to you to display the actual message to the user, otherwise on error the job will exit without explanation.  The error statement is contained within a system variable called {Exception}.

EXAMPLE:

Say a job contained the following code (with a SQL error in it - missing quotation mark):

<Job>
 <SQLExec> Update TempTable set  MyField='Setting1 where TempTableID='XXX'</SQLExec>
</Job>

Add error handling as follows:

<Job>
  <Block>
 <SQLExec> Update TempTable set  MyField='Setting1 where TempTableID='XXX'</SQLExec>
 </Block>
 <Catch>
   <MessageDialog text="{Exception}"/>
 </Catch>
</Job>

The <Block> would therefore effectively encompase the entire job (less of course the <Catch>).


(Please Note: This Procedure can be destructive and should only be used by Advanced Users.  RADical Systems (UK) Limited or its Partners cannot be held responsible, in anyway, for any consequence of using this or any other Database Function, Procedure or SQL command.  Responsibility resides solely with the user.  

IT IS HIGHLY RECOMMENDED THAT A FULL AND VALID SPACE MANAGER DATABASE BACKUP IS TAKEN AND VERIFIED AS VALID BEFORE MAKING ANY CHANGES TO THE DATABASE.)