I am getting an error when updating a DataWindow wh开发者_StackOverflow中文版ich says "Row changed between retrieve and update". What is the solution?
This can occur if you are displaying the same row(s) in more than one (non-shared) DataWindow and then try to update them both. Other causes are incorrect use of SetItemStatus(); incorrect use of the status flags on the update() statement; and finally, the cause this is intended to detect, another user updated the row before you.
Has this been resolved? There are several reasons this could happen, one is if the row has been updated by another user. In the update properties of your dataobject you can choose update method, either using key value, key and modified values, or key and all updatable columns.
If you are SURE there is not concurrency concerns then you can change this setting to "use key value only". It will make the where clause for updates consist of the key value only and other columns will not be evaluated for changes.
It can happen if validation errors occur, you need to remember to set the item status to not modified. To set all rows to not modified you'd do dw_1.setitemstatus(1,0,Primary!,NotModified!) if my memory is correct that would set all columns for row one to NotMofidied!. You can also do a ResetUpdate() or Reretrieve the data.
hope this helps. Rich
This usually means that some column youve included in the update where clause is bing updated somewhere else, such as through a trigger. another causes include not having empty string is null set for string columns when talking to oracle. oracle converts any empty string send to it to nulls, so a subsequent update wont find the same row unless you tell pb to treat it as null as well. look at the columns you've told pb to include in the where clause ( in the update specs ) and make sure they are really columns you need to have there.
I realize this is an old question, but figured I'd add my solution in case it helps anyone. In my case, the datawindow was issuing an UPDATE
statement and when that statement was run in SQL management studio, the columns returned match what should have been expected. However, the query showed two times where (1 row(s) affected). A trigger was updating a row not related to the table being updated. Adding SET NOCOUNT ON
to that trigger resulted in 1 instance where (1 row(s) affected) and the Row Changed between retrieve and update was resolved.
This can also happen when you have two datawindow rows that update the same database row or rows.
(A not-so-good) Example:
The table has no primary key, but the datawindow uses the DateOfBirth.
Name: Dennis Miller DateOfBirth: 19531103 Vocation: comedian
Name: Kate Capshaw DateOfBirth: 19531103 Vocation: actress
Notice that Dennis and Kate have the same DateOfBirth.
Let us presume that these changes are made
Name: Mr. Dennis Miller
Name: Ms. Kate Capshaw
When dw_1.update() is invoked, this message appears:
"Row changed between retrieve and update"
because each row was updated twice, first with 'Mr. Dennis Miller' and then with 'Ms. Kate Capshaw'
Another possibility is that the datawindow column definition does not match the database column definition.
Example:
columnA is defined in database as char(10)
datawindow is built with columnA as char(10)
columnA is altered to char(20) in database
data is added externally to columnA with more than 10 characters.
datawindow retrieve truncates to 10 characters (with or without error depending on application settings.)
delete/update row may yield "Row changed between retrieve and update"
This behavior is monitored by the 'Update properties' of your datawindow and more specifically by the part 'Where clause for Update/Delete'. This controls the 'where' clause that will be used by Powerbuilder upon updating.deleting, as you could check by using the SQLPreview event of your Datawindow:
- Key columns: only the key columns are used in the where clause. If you use this, you have the risk that some columns have been modified elsewhere (non necessarily by PowerBuilder) between your retrieval and your update. Only the latest update will remain in the DB. Of course, if the key columns thelselves have been modified, you will get the message 'Row changed'.
- Key and updatable columns: on top of the key columns, you add all the updatable columns, as defined immediately under, in the box 'Updatable columns'. Whenever a column has been modified (again not necessarily using Powerbuilder), the row will not be retrieved and you will get the message 'Row changed'. In many cases, this is overkill.
- Key and modified columns: only columns modified for the specific row are added to they key.
Now it is up to you to choose one of these, depending on the specific context of your application.
精彩评论