ON_ERROR_DO Statement


SYNTAX:
 
on_error_do = ON_ERROR_DO { stmt } END_ON_ERROR_DO ';' .

If any error occurs during XPX execution, control is transferred to the fisrt statement in the last seen ON_ERROR_DO block. When ON_ERROR_DO_BLOCK is complete, control will resume at stament following the statement that threw the error. Hence, eexception handling may be disabled by supplying an empty ON_ERROR_DO block.

Example:

-- function snippet will return value of second element if it is possible, if not return value of first element in list
-- if first element is possible either, return -1

ON_ERROR_DO
    RETURN(-1);
END_ON_ERROR_DO;

x := xlist[1];
ON_ERROR_DO ; ON_ERROR_DO; – cancel error handling for next access
x := xlist[2];
RETURN(x);