SET EXCEPTION

Triggers an exception handler in the absence of an exception condition.

Syntax

SET EXCEPTION condition

Parameters

condition

Can be
BREAK
Mimics a terminal or process "break" condition (i.e., the user pressing the "break" key).
DEADLOCK
Mimics a deadlock in a multi-user system. Does not abort the current transaction.
ERROR
Mimics an error condition.
WARNING
Mimics a warning condition.

Comments

A SET EXCEPTION command mimics the specified condition, triggering the associated exception handler, if such a handler has been declared (by the ON command).

The SET EXCEPTION command cannot be used in the body of an exception handler.

The SET EXCEPTION command has no effect on system variables such as $InTransaction, $ErrCode, or $ErrLevel.

The SET EXCEPTION command is not affected by the SET RESET and SET RESTORE commands.

Example

localprocedure LocProc (inout $Deadlock)
 on deadlock
  let $Deadlock = $true
  return
 endon
 ... other commands ...
endprocedure
procedure MainProc ()
 on deadlock
  goto RetryTransaction
 endon
 ... other commands ...
 RetryTransaction:
 transaction
  ... other commands ...
  LocProc ($Deadlock)
  if $Deadlock = $true
   set exception deadlock
  endif
  ... other commands ...
 endtransaction
endprocedure

In the preceding example, SET EXCEPTION mimics a DEADLOCK condition, triggering the declared deadlock exception handler in one procedure when the deadlock has actually occurred in another procedure.

 

Related Topics