UNDO scope and relationship to a CATCH block
- Last Updated: October 18, 2024
- 1 minute read
- OpenEdge
- Version 12.2
- Documentation
Because the CATCH block only executes when ERROR or
STOP is raised in the associated block, any transaction within the
associated block is already undone. In other words, changes made within the associated
block to persistent data, undo variables, and undo temp-table fields have been
discarded. In addition, buffers scoped to the associated block of the
CATCH block are not available when the CATCH block
executes. This is because either the buffer was undone and released, or committed and
released. If a buffer referenced in a CATCH block is referenced outside
of the associated block, then the scope of that buffer is the smallest enclosing block
outside of the associated block that encompasses all references to the buffer.
Therefore, these buffers are available to the CATCH block.
The CATCH block itself is an undoable
block with implicit ON ERROR UNDO, THROW error
handling. You cannot explicitly override the ON ERROR
directive for a CATCH block.
A statement that raises ERROR or STOP within a CATCH block
causes the following to occur, unless the condition is handled within the block:
UNDOtheCATCHblock if it contains a transaction.-
LEAVEthe associated block. -
THROWthe condition to the block enclosing the associated block, or to the caller if there is no outer block.
The following example demonstrates these availability rules:
|