DataWindow Error: Row changed between retrieve and update
Asked Answered
S

7

6

I am getting an error when updating a DataWindow which says "Row changed between retrieve and update". What is the solution?

Sandglass answered 7/7, 2010 at 7:36 Comment(0)
L
5

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.

Leslielesly answered 7/7, 2010 at 14:15 Comment(1)
Also see Terry's writeup on Database Irregularities.Leslielesly
M
2

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

Mortician answered 1/9, 2010 at 14:42 Comment(0)
C
2

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.

Casar answered 10/10, 2010 at 16:12 Comment(0)
M
2

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.

Mediatize answered 26/8, 2016 at 19:38 Comment(0)
S
1

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'

Stomach answered 23/4, 2012 at 19:29 Comment(1)
In this case you could add gender and zip code to the key.Leslielesly
S
0

Another possibility is that the datawindow column definition does not match the database column definition.

Example:

  1. columnA is defined in database as char(10)

  2. datawindow is built with columnA as char(10)

  3. columnA is altered to char(20) in database

  4. data is added externally to columnA with more than 10 characters.

  5. datawindow retrieve truncates to 10 characters (with or without error depending on application settings.)

  6. delete/update row may yield "Row changed between retrieve and update"

Stomach answered 29/8, 2017 at 18:50 Comment(0)
F
0

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:

  1. 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'.
  2. 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.
  3. 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.
Froma answered 31/8, 2017 at 11:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.