数据窗口错误:检索和更新之间行发生更改

发布于 2024-09-08 03:46:22 字数 44 浏览 2 评论 0原文

更新数据窗口时出现错误,显示“检索和更新之间的行已更改”。解决办法是什么?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

隐诗 2024-09-15 03:46:22

如果您在多个(非共享)数据窗口中显示相同的行,然后尝试同时更新它们,则可能会发生这种情况。其他原因是 SetItemStatus() 的使用不正确; update() 语句中状态标志的错误使用;最后,这是要检测的原因,另一个用户在您之前更新了该行。

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.

£冰雨忧蓝° 2024-09-15 03:46:22

这个问题解决了吗?发生这种情况的原因有多种,其中之一是该行已被其他用户更新。在数据对象的更新属性中,您可以选择更新方法,使用键值、键和修改值,或键和所有可更新列。

如果您确定不存在并发问题,那么您可以将此设置更改为“仅使用键值”。它将使得更新的 where 子句仅包含键值,并且不会评估其他列的更改。

如果发生验证错误,则可能会发生这种情况,您需要记住将项目状态设置为未修改。要将所有行设置为不修改,您需要执行 dw_1.setitemstatus(1,0,Primary!,NotModified!) 如果我的记忆正确的话,会将第一行的所有列设置为 NotMofidied!。您还可以执行 ResetUpdate() 或重新检索数据。

希望这有帮助。
富有的

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

演多会厌 2024-09-15 03:46:22

这通常意味着您包含在 update where 子句中的某些列正在其他地方更新,例如通过触发器。另一个原因包括在与 Oracle 通信时没有为字符串列设置空字符串为空。 oracle 将发送给它的任何空字符串转换为 null,因此后续更新不会找到同一行,除非您告诉 pb 将其也视为 null。查看您告诉 pb 包含在 where 子句(在更新规范中)中的列,并确保它们确实是您需要的列。

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.

月野兔 2024-09-15 03:46:22

我意识到这是一个老问题,但我想我会添加我的解决方案,以防它对任何人有帮助。在我的例子中,数据窗口发出一个 UPDATE 语句,当该语句在 SQL Management Studio 中运行时,返回的列与预期相匹配。但是,查询显示两次(1 行受影响)。触发器正在更新与正在更新的表无关的行。向该触发器添加 SET NOCOUNT ON 会导致 1 个实例(1 行受到影响),并且检索和更新之间的行更改已得到解决。

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.

话少情深 2024-09-15 03:46:22

当您有两个数据窗口行更新同一数据库行时,也会发生这种情况。

(不太好)示例:

表没有主键,但数据窗口使用 DateOfBirth。

   Name:           Dennis Miller
   DateOfBirth:    19531103
   Vocation:       comedian
   Name:           Kate Capshaw
   DateOfBirth:    19531103
   Vocation:       actress

请注意,丹尼斯和凯特有相同的出生日期。

让我们假设进行了这些更改,

   Name:           Mr. Dennis Miller
   Name:           Ms. Kate Capshaw

当调用 dw_1.update() 时,会出现以下消息:

   "Row changed between retrieve and update"

因为每行更新了两次,首先是“Mr.”。丹尼斯·米勒”,然后是“丹尼斯·米勒女士”。凯特·卡普肖

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'

゛清羽墨安 2024-09-15 03:46:22

另一种可能性是数据窗口列定义与数据库列定义不匹配。

示例:

  1. columnA 在数据库中定义为 char(10)

  2. datawindow 是使用 columnA 构建的,作为 char(10)

  3. columnA 在数据库中更改为 char(20)

  4. 数据从外部添加到 columnA,且长度超过 10 个字符。

    p>

  5. datawindow 检索截断为 10 个字符(有或没有错误,具体取决于应用程序设置。)

  6. 删除/更新行可能会产生“在检索和更新之间更改行”

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"

一瞬间的火花 2024-09-15 03:46:22

此行为由数据窗口的“更新属性”监控,更具体地说,由“更新/删除的Where 子句”部分监控。这控制 Powerbuilder 在更新时使用的“where”子句。删除,您可以使用数据窗口的 SQLPreview 事件进行检查:

  1. 键列: 仅在 where 中使用键列条款。如果您使用此功能,您将面临在检索和更新之间某些列已在其他地方(不一定是由 PowerBuilder)修改的风险。只有最新的更新才会保留在数据库中。当然,如果键列本身已被修改,您将收到消息“行已更改”。
  2. 关键列和可更新列:在关键列的顶部,您可以添加所有可更新列,如下面的“可更新列”框中所定义。每当修改一列(同样不一定使用 Powerbuilder)时,将不会检索该行,并且您将收到消息“行已更改”。在许多情况下,这是矫枉过正的。
  3. 键和修改的列:只有针对特定行修改的列才会添加到它们的键中。
    现在您可以根据应用程序的具体情况选择其中之一。

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文