Nested, weak-scoped references to the same buffer
- Last Updated: January 16, 2024
- 1 minute read
- OpenEdge
- Version 12.8
- Documentation
Nested, weak-scoped references to the same buffer
Record Buffer Rule 2: You cannot nest two weak-scoped references to the same buffer.
For example, this procedure violates this rule:
|
If you try to run this procedure, you get the error shown in the following figure that tells you that your buffer references are invalid.
When you think about it, this is perfectly sensible and necessary. Picture this situation:
The AVM is using the Customer buffer for the current
Customer record in the outer FOR EACH
block. The first time through the block, it contains the New Hampshire
Customer with the highest CreditLimit. Now suddenly the
AVM gets a request to use that same buffer to start another FOR
EACH block, while it is still in the middle of processing the outer one. This
could not possibly work. If the AVM replaced the New Hampshire Customer
with whatever Customer was the first one to satisfy the selection of
Customers with higher CreditLimits and then you had
another reference to the first Customer later on in the outer block (which would be
perfectly valid), that Customer record would no longer be available because
the AVM would have used the same buffer for the inner FOR
EACH block. Because this cannot be made to work with both blocks sharing the same
buffer at the same time, this construct is invalid.