The ON statement establishes the action to be executed for any subsequent raising of an enabled condition in the scope of the established condition.
|
If SNAP and SYSTEM are specified, the implicit action is followed immediately by SNAP information.
The ON-unit can be either a single unlabeled simple statement or an unlabeled begin-block. If it is a simple statement, it can be any statement except BEGIN, DECLARE, DEFAULT, DO, END, ENTRY, FORMAT, ITERATE, LEAVE, OTHERWISE, PROCEDURE, RETURN, SELECT, WHEN, or %statements. If the ON-unit is a begin-block, a RETURN statement can appear only within a procedure nested within the begin-block; a LEAVE statement can appear only within a do-group nested within the begin-block.
Except for ON-units consisting only of either a semicolon (;) or the RESIGNAL statement, an ON-unit is treated as a procedure (without parameters) that is internal to the block in which it appears. Any names referenced in an ON-unit are those known in the environment in which the ON statement for that ON-unit was executed, rather than the environment in which the condition was raised.
When execution of the ON-unit is complete, control generally returns to the block from which the ON-unit was entered. Just as with a procedure, control can be transferred out of an ON-unit by a GO TO statement. In this case, control is transferred to the point specified in the GO TO, and a normal return does not occur.
The specific point to which control returns from an ON-unit varies for different conditions. Normal return for each condition is described in Conditions.