ROW-STATE attribute
- Last Updated: March 30, 2020
- 3 minute read
- OpenEdge
- Version 12.2
- Documentation
ROW-STATE attribute
There is a ROW-STATE attribute on
the temp-table buffer in both the after-table and the before-table
to allow you to determine how, if at all, each record has been changed. ROW-STATE is
an integer value representing one of these constants, which you
can and should use to identify the meaning of the ROW-STATE:
-
0=ROW-UNMODIFIED -
1=ROW-DELETED -
2=ROW-MODIFIED -
3=ROW-CREATED
Note that these are
un-quoted literals that correspond to integer values, much like
the values NO-LOCK, SHARE-LOCK,
and EXCLUSIVE-LOCK for LOCK-MODE.
You use the literals in ABL logic, in statements such as this:
|
If you display the ROW-STATE,
it is displayed as an integer.
Each record in the after-table
that has been modified or added has an internal pointer to its counterpart
in the before-table. These after-table records have a ROW-STATE value
of ROW-MODIFIED or ROW-CREATED, depending
on whether the row has been added to the temp-table since TRACKING-CHANGES was
set to true. Deleted records do not appear in the after-table, because
it reflects the current state of the data. Records in the after-table
that have not been added or changed have a ROW-STATE of ROW-UNMODIFIED. These
records have no counterpart in the before-table.
Every record
in the before-table has a nonzero ROW-STATE because
every record is the before-image for a deleted, created, or modified
record. Records in the before-table can have a ROW-STATE equal
to one of these values:
-
ROW-DELETED— A deleted row in the before-table holds the original field values of the record at the timeTRACKING-CHANGESwas set to true. It has no counterpart in the after-table. A record is moved from the after-table to the before-table when it is deleted. Thus, the only way to locate deleted records is in the before-table. If a record is modified and then later deleted before changes are processed, then its state isROW-DELETEDand there is no record of the changes made before that. -
ROW-MODIFIED— A modified row in the before-table holds the field values of the record at the time thatTRACKING-CHANGESwas last set to true. The row is copied from the after-table when it is first changed. No intermediate changes between the "original" values and the latest values are saved anywhere. -
ROW-CREATED— A newly created row is created in the before-table at the same time that the equivalent record is created in the after-table. The before-table row for a created row does not hold any meaningful field values. It serves merely as a placeholder for the row so that you can identify created rows along with modified and deleted ones by looking at the before-table. The field values in the after-table can then be changed as the record is edited, just as for changed rows. TheROW-STATEremainsROW-CREATEDuntil changes to the table have been processed, regardless of how many times field values have been modified in the meantime.
Records
in the after-table can have a ROW-STATE of ROW-UNMODIFIED, ROW-CREATED,
or ROW-MODIFIED. This means that new records and changed
records can be tracked through either table. However, because deleted records
are removed from the after-table, they can be tracked only through
the before-table. In general, you should process changes through
the before-table for this reason.
ROW-STATE attribute changes to ROW-MODIFIED, in spite of the fact that the record's value remains the same. As
a result, GET-CHANGES can return records that don't appear to have been
changed.