As outlined in the previous section, the first step in saving a change is to locate the database buffer the temp-table row was derived from. The AVM can always determine how to identify that row, based on the KEYS phrase of the Data-Source or the primary key of the database table, but it is not always trivial for you to determine the same information in your procedures.
For this reason, there is a SAVE-WHERE-STRING attribute on the Data-Source to return to you the where-clause you would need to use to retrieve the same record yourself, as shown:
As with SAVE-ROW-CHANGES, SAVE-WHERE-STRING defaults to the first (or only) buffer in the Data-Source. The attribute value is set internally by the AVM to be the where-clause phrase (including the initial keyword WHERE) needed to find the database buffer identified by the buffer-index or buffer-name within the Data-Source. This can be useful when you need to build up custom code to retrieve database records of changed buffers, if using the SAVE-ROW-CHANGES method is not adequate. If you specify a buffer-index, it is the sequential position of the buffer within the list of multiple buffers for the Data-Source. If you specify the buffer-name, it must be the name of an after-table buffer in the list of buffers attached to the Data-Source. The buffer must be one that has a before-table, either static or dynamic. The attribute value qualifies field names in the buffer's temp-table with the before-table name, not the after-table name. This is because this string can be used to find database records based on field values in the before-table rows, as your code is cycling through the before-table, processing each change.
If an error occurs during the database update, the ERROR attribute is set to true for the ProDataSet, the temp-table where the error occurred, and the buffer where the error occurred.
The following table summarizes all these change methods and the handles they can be used on.
Method name
ProDataSet handle
Temp-table buffer handle
ROW version
GET-CHANGES
Yes
Yes
None
SAVE-ROW-CHANGES
No
No
Only
MERGE-CHANGES
Yes
Yes
MERGE-ROW-CHANGES
ACCEPT-CHANGES
Yes
Yes
ACCEPT-ROW-CHANGES
REJECT-CHANGES
Yes
Yes
REJECT-ROW-CHANGES
In summary:
You execute a method on a ProDataSet handle to affect the entire ProDataSet.
You execute a method on a temp-table buffer handle to affect that one temp-table.
You do not execute any of these methods on a temp-table handle. However, the TRACKING-CHANGES attribute is on the temp-table handle.
There is no row-level method for GET-CHANGES. You execute this only for an entire temp-table or ProDataSet.
There is only a row-level method for saving changes.
The row-level method is executed on the temp-table buffer handle. The name tells the AVM whether to act on a single row or the entire table.