Group assignments with the ASSIGN statement
- Last Updated: October 4, 2023
- 1 minute read
- OpenEdge
- Version 13.0
- Documentation
ASSIGN keyword. Even if the
values being assigned have nothing to do with one another, it is faster to do it in a
single statement, as in this example:
|
Here the code is setting an attribute on a procedure handle, a variable, and a field
attribute. Even though these are unrelated, it is still best to ASSIGN
them together.
If you are assigning multiple field values within a single record buffer, the
ASSIGN statement can be even more important. the AVM adjusts index
entries and does other work as part of each statement. If you assign two fields that
participate in the same index in two separate statements, the index block is rebuilt
once after each statement—a much greater overhead than doing it in one statement. In
fact, because the AVM assigns index entries at the end of each statement, you might even
cause a temporary (but fatal) unique index violation if you assign part of a composite
key in one statement and the other part in another. Don’t ever do this.
ASSIGN statement without multiple
assignments, some ABL developers always use the ASSIGN keyword even
when the statement only does one assignment. There is no advantage to this. That is,
these two statements are comparably fast:
|