Examples using FINALLY blocks
- Last Updated: October 18, 2024
- 2 minute read
- OpenEdge
- Version 12.2
- Documentation
The examples that follow demonstrate common
use cases for FINALLY blocks.
Example 1
In Example 1, the FINALLY block executes before any flow-of-control
options (LEAVE, NEXT, RETRY,
RETURN, or THROW) are executed for the associated
block. For iterating blocks, the FINALLY block executes after each
iteration of the block:
|
If you run this code, you see the following messages:
|
Example 2
In Example 2, after ERROR is raised, execution goes to the
CATCH block and then to the FINALLY block.
|
If you run this code, you see the following messages:
|
Example 3
In Example 3, after ERROR is raised, execution goes to the
CATCH block, which rethrows the error. The FINALLY block
executes for the DO block before the ERROR is raised in
the procedure block. The MESSAGE statement there does not execute because
of the raised error, but the outer FINALLY runs.
|
If you run this code, you see the following messages:
|