Kbase P136363: Changes from other users are overwritten even when PREFER-DATASET is FALSE
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  22/10/2008 |
|
Status: Unverified
SYMPTOM(s):
Changes from other users are overwritten even when PREFER-DATASET is FALSE
proDataSet changes overwrite modified records when table has no unique index
FACT(s) (Environment):
All Supported Operating Systems
OpenEdge 10.x
OpenEdge Language Category: ProDataSets
CAUSE:
Updating data in a buffer using a proDataSet, and setting the DATA-SOURCE object's PREFER-DATASET attribute to FALSE, indicates that if the record has been changed since it was fetched into the dataset an error condition should be raised and SAVE-ROW-CHANGES should fail.
This all depends upon the dataset's ability to find the updated record in the database table uniquely. Typically this is handled internally by the proDataSet code using the KEYS that were specified when attaching the DATA-SOURCE or that were extrapolated by the proDataSet code based on common indices between the source and target tables. If the source table has no unique key, or the KEYS option in the DATA-SOURCE mapping uses a non-unique index, then the dataset may not be able to detect that the record has changed and will overwrite the first record it encounters with the changes.
This is expected behavior and it is basically bad design to have a table without at least one unique index.
FIX:
When attaching proDataSet tables to a data-source based on a table with a non-unique index you should instead map it to a ROWID. The way this is done is by adding a ROWID field to your proDataSet temp-table and in the ATTACH-DATA-SOURCE method specify something like the following:
hBuffer:ATTACH-DATA-SOURCE(hDataSource,"ROWID(<dbtable>),<temptable>.<rowidfield>").
This should be done when filling the dataset as well as saving changes.