Usage of labels
- Last Updated: March 30, 2020
- 1 minute read
- OpenEdge
- Version 12.2
- Documentation
Labels can be used to undo the transaction associated with the outer block, rather than just the subtransaction of the inner block.
The following example sets up a common set of nested FOR EACH blocks that list the order numbers for the first few customer records
in the Sports2000 database. Within the inner block, a nonsensical FIND statement raises error after the first iteration. This trivial framework
allows you to test the interactions of ON ERROR phrases.
|
The flow of this example is as follows:
- The
ASSIGNstatement inOuter-Blockstarts a transaction. - The
FINDstatement inInner-Blockraises theERRORcondition. - The error message is displayed.
- The explicit
ON ERRORphrase ofInner-Blockactivates, causing the entireOuter-Blocktransaction to be undone, and aRETURNto the main block. - The string "Procedure NestedBlocks Complete." is displayed.