TRY ... FINALLY

Syntax

   TRY 
     statementList1 
   FINALLY 
     statementList2 
   END

where each statementList is a sequence of statements delimited by semicolons.

Description

The TRY…FINALLY statement executes the statements in statementList1 (the TRY clause). If statementList1 finishes without raising any exceptions, statementList2 (the FINALLY clause) is executed. If an exception is raised during execution of statementList1, control is transferred to statementList2; once statementList2 finishes executing, the exception is re-raised.

If a call to the Exit procedure causes the control to leave statementList1, statementList2 is automatically executed. Thus the FINALLY clause is always executed, regardless of how the TRY clause terminates.

Example

   execute ibeblock
   as
   begin
     i = 1;
     try
       i = i/0; <-- Here an will be exception raised...
     finally
       i = 2;   <-- ... but this statement will be executed anyway
     end
     i = 3;     <-- This statement will not be executed
   end