SAVE-ROW-CHANGES / PREFER-DATASET / MERGE-BY-FIELD

Posted by Rom Elwell on 22-Sep-2014 14:36

ANSWERED in the description for SAVE-ROW-CHANGES.

 

SETUP:

PREFER-DATASET is set to FALSE (Default setting)

MERGE-BY-FIELD is set to TRUE (Default setting)

TEST:

User Sally requests the Department record for Department ID 001.

User Joe requests the Department record for Department ID 001.

Sally updates the Department Category code from 'AAA' to 'BBB'.

Sally commits her update, calling SAVE-ROW-CHANGES.

Joe updates the Department Status from 'Active' to 'Inactive'.

Joe attempts to commit his update, calling SAVE-ROW-CHANGES, however the DB sets ERROR-STATUS:ERROR because the before-image for Joe's record has been updated (Sally's change to the field Category Code) in the DB since Joe first requested the record.

QUESTION:

Using a combination of SAVE-ROW-CHANGES, PREFER-DATASET and possibly MERGE-BY-FIELD (or another property), is it possible to save Joe's updates and return to the caller an updated record that has both Joe's update and the earlier update from Sally to another field in the same record, without causing ERROR-STATUS:ERROR to be set?

Posted by Rom Elwell on 22-Sep-2014 15:05

If the data in the data source has changed, the AVM saves the ProDataSet buffer changes based

on the current PREFER-DATASET attribute setting. When PREFER-DATASET is TRUE, the

AVM copies the data from ProDataSet buffer or field to the data source regardless of any

changes made to the data in the data source since the data was read. When PREFER-DATASET

is FALSE, the AVM does not copy the data from the ProDataSet buffer or field to the data

source. The AVM copies the conflicting data from the data source to the ProDataSet buffer or

field, instead, and sets the ERROR attribute and DATA-SOURCE-MODIFIED attribute to

TRUE.

All Replies

Posted by Rom Elwell on 22-Sep-2014 15:05

If the data in the data source has changed, the AVM saves the ProDataSet buffer changes based

on the current PREFER-DATASET attribute setting. When PREFER-DATASET is TRUE, the

AVM copies the data from ProDataSet buffer or field to the data source regardless of any

changes made to the data in the data source since the data was read. When PREFER-DATASET

is FALSE, the AVM does not copy the data from the ProDataSet buffer or field to the data

source. The AVM copies the conflicting data from the data source to the ProDataSet buffer or

field, instead, and sets the ERROR attribute and DATA-SOURCE-MODIFIED attribute to

TRUE.

Posted by mihai.pintea on 23-Sep-2014 01:58

The method MERGE-ROW-CHANGES could solve the problem.

MERGE-ROW-CHANGES( ) method:

Merges a single changed row from a ProDataSet object loaded with the GET-CHANGES( ) method into the corresponding row in the original ProDataSet temp-table buffer.

Syntax:  change-handle:MERGE-ROW-CHANGES( [ original-handle [, copy-all-mode ] ] )

More details can be found on Progress Help.

This thread is closed