Kbase P74353: ADM2. Update Operations against RowObjUpd
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  15/02/2005 |
|
Status: Verified
GOAL:
ADM2. Update Operations against RowObjUpd
GOAL:
The Update Operations and the RowObjUpd Temp?table
GOAL:
Nondata Fields in the RowObject and RowObjUpd Temp?tables
FACT(s) (Environment):
Progress 9.x
OpenEdge 10.x
FIX:
The Update Operations and the RowObjUpd Temp?table
SmartDataObject update operations require an additional Progress temp?table called RowObjUpd. This temp?table, a copy of the RowObject temp?table, is used for handling all types of changes to data rows: updating existing rows, adding rows, and deleting rows:
When an existing row is updated, Progress creates in RowObjUpd a before image of the row; that is, the row with its original row values, as it appeared before the update. When the update is committed, the updated version of the row is also written to the RowObjUpd table. The server-side code uses the before image to verify that the row?s data has not been changed by another user since it was read, then uses the new values to make the updates to the database.
When a row is added and the add is committed, the new row is written to the RowObjUpd table.
When a row is deleted, the deleted row is removed from the RowObject table and written to the RowObjUpd table to be passed to the server.
The SmartDataObject transfers updated and newly added rows back to the database when it receives a Commit request. Depending on how the SmartDataObject?s AutoCommit property is set, the commit can be performed either automatically when an update is received (the default behavior) or when a specific Commit request is received after a set of updates have been made. The default behavior is the typical usage; however, to change to the nondefault behavior, set the SmartDataObject?s AutoCommit property to NO. (For details, see the "Commit SmartPanel" section in Chapter 5, "Data Management in the ADM.")
When a change is committed, the RowObjUpd temp?table is passed back to the server (if the SmartDataObject is divided between client and AppServer), and the code in serverCommit reads the table and makes the appropriate changes to the database. (See the field description of RowMod in the "Nondata Fields in the RowObject and RowObjUpd Temp?tables" section for details.)
Nondata Fields in the RowObject and RowObjUpd Temp?tables
A RowObject temp?table contains more than just fields selected from database tables. It also contains the following information:
A temp?table definition (the first line of the table)
Field definitions for the temp?table data (corresponds to the database data)
Field definitions for the temp?table itself
Index definitions
For example:
DEFINE TEMP-TABLE RowObject RCODE-INFORMATION
FIELD Cust-Num LIKE Customer.Cust-Num VALIDATE
FIELD Name LIKE Customer.Name VALIDATE
FIELD Address LIKE Customer.Address VALIDATE
FIELD City LIKE Customer.City VALIDATE
FIELD State LIKE Customer.State VALIDATE
FIELD Postal-Code LIKE Customer.Postal-Code VALIDATE
FIELD RowNum AS INTEGER
FIELD RowIdent AS CHARACTER
FIELD RowMod AS CHARACTER
INDEX RowNum IS PRIMARY RowNum
INDEX RowMod RowMod
INDEX RowIdent RowIdent.
Note that the RowObject temp?table contains three special fields named RowNum, RowIdent, and RowMod. These fields. which are maintained by the SmartDataObject support code, are used to manage queries and updates as follows:
RowNum?An integer value that represents the sequence number of the row within the query?s result set. A unique value is assigned to each row as it is added to the table; it is used basically to keep the rows in a consistent sort order. The values begin arbitrarily with 900,000, which generally assures that the values of this field remain positive whether the temp?table is built forward or backward.
RowIdent?A character field that contains a comma-separated list of the ROWIDs of the database records from which the RowObject row is derived. The database ROWIDs are used to re-retrieve the records from the. database when performing an update. Note that if the records in the RowObject temp?table result from a join, the ROWIDs in this field are a combination of the ROWIDs for the joined tables.
RowMod?A character field that contains a one-character code that indicates the kind of update operation performed on a row:
For a newly added row, RowMod is set to ?A? if the row results from an Add operation or ?C? if it is results from a Copy operation.
For a row that is to be deleted, RowMod is set to ?D?.
An Update operation returns two rows: a copy of the row as it was received, for which RowMod is set to ??, and the row with its changes, for which RowMod is set to ?U?. The copy of the row as received is used to verify that the corresponding database records have not been changed since the user accessed the row, and the row with changes is used to update the database.
The RowObjUpd temp?table contains the same fields as the RowObject temp?table plus the ChangedFields field, which is used only for updates:
ChangedFields (RowObjUpd temp?table only)?A character field that contains a comma-separated list of the names of all SmartDataObject columns in the current row that have been modified. This list is used to ensure that only those fields that have not previously been changed are written back to the database, in order to minimize interference between different users of an application who might be changing different fields in the same record. This field is maintained automatically by the SmartDataObject support code regardless of how each field?s value may have been changed..