祝愿大家身体健康!

 站点注册  找回密码
 站点注册

QQ登录

只需一步,快速开始

查看: 5566|回复: 3

[转帖] 如何处理错误 “Row Changed Between Retrieve and Update”

[复制链接]

[转帖] 如何处理错误 “Row Changed Between Retrieve and Update”

[复制链接]
ehxz

主题

0

回帖

58万

积分

管理员

积分
588551
贡献
在线时间
小时
2007-6-26 12:42:51 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?站点注册

×
 

如何处理错误 “Row Changed Between Retrieve and Update”

 
  
 
         Row Changed Between Retrieve and Update

  This is a common but frustrating error that can create real problems. The cause for this error is one or more of the following:

  1. A primary key for the table is not listed in the Update Properties for the DataWindow.
  2. The primary key selected allows and has duplicates.
  3. The Update Properties for the DataWindow are improperly set for the needs of the application.
  4. The data did actually change.

  If no primary key is listed, this is usually the result of either the DataWindow being created on a table that did not have a primary key when the DataWindow was created or the DataWindow was created and Allow Updates was not checked and later checked.

  NOTE: If at a later time, the Allow Updates is checked and you select the Table to Update, the Updateable Columns and Key Columns MUST be selected since they are not automatically selected.

  There are cases that the primary key selected is not a "true primary key" in that there can be duplicates records for each key. In this case the error will only occur when there are actual duplicates for the selected key. Often this error will go undetected for a long time until a duplicate value is present. This is a hard one to find since the error will occur on the duplicate value only. This appears to be an intermitted error.

  Specifying the WHERE clause for update/delete

  Sometimes multiple users are accessing the same tables at the same times and in cases, they may be actually accessing the same data at the same time. This may be a desired situation and the correct update/delete specification will protect the data from corruption.

  Key Columns:

  This is the least restrictive and will data corruption. This can only be safely used in single user environments and in multi-user environments when the developer can be 100% sure that only one user at a time will access the data.

  The danger of this is that since the key column is the only column specified in the WHERE clause, another user can change the data after you retrieve it and when you save, your data will over write the other users data. The only warning you would get is if the key column changed, which is very unlikely.

  Key and Updateable Columns:

  This is the PowerBuilder default and provides the greatest level of granularity but may be too restrictive for the needs of the application. The WHERE clause contains ALL the updateable columns that were selected in the Update Properties of the DataWindow NOT just the updated (modified) columns.

  This will guarantee that only one user can update a row at a time. The problem may arise when two users retrieve the same row and each changes different data elements (i.e. one user updates the address of the customer and another updates the middle name). The first user to save the data will be OK and the other user update will fail.

  Key and Modified Columns

  This is usually a good setting for most multi-user applications. This allows for multiple users to access the same row and both make changes to different data elements of the row.

  This would prevent the problem above (i.e. one user updates the address of a customer and another updates the middle name). With this setting, both users would be able to successfully save the data without any negative impact on the other users data.

  Correcting Changed Data

  To correct data errors caused from data changing between retrieve and update (except for duplicate keys) the following method is an example of what can be employed:

  If a row is changed, the DbError event will be triggered with a value of –3 in the argument sqldbcode and the row number of the failure in the argument row. A message can be displayed to the user and the row highlighted for the user to see. Allow the user the option to re-retrieve the changed row or discard it. If the user chooses to re-retrieve the changed data, use the ReSelect() PowerBuilder function. This will re-retrieve ONLY the row specified. This will allow the user to see the changes to the row and permit them to make any additional changes they desire.

IMPORTANT: PowerBuilder will stop the update process upon encountering the first error. The update process can be re-called or stopped at this error. It is usually best to continue the update process. This will update the database with all other changes and/or mark any other error rows. If the row that caused the error is in the Filter buffer, you must unfilter it if you want the user to correct the problem.

  Code a –1 as the return value for the DbError event, this will suppress the default PowerBuilder error box and allow you to display your own message.

 

 

   
共享共进共赢Sharing And Win-win Results
SYBASEBBS - 免责申明1、欢迎访问“SYBASEBBS.COM”,本文内容及相关资源来源于网络,版权归版权方所有!本站原创内容版权归本站所有,请勿转载!
2、本文内容仅代表作者观点,不代表本站立场,作者自负,本站资源仅供学习研究,请勿非法使用,否则后果自负!请下载后24小时内删除!
3、本文内容,包括但不限于源码、文字、图片等,仅供参考。本站不对其安全性,正确性等作出保证。但本站会尽量审核会员发表的内容。
4、如本帖侵犯到任何版权问题,请立即告知本站 ,本站将及时删除并致以最深的歉意!客服邮箱:admin@sybasebbs.com
lovelyni

主题

0

回帖

76

积分

注册会员

积分
76
贡献
在线时间
小时
2007-12-19 22:07:49 | 显示全部楼层
英文啊,看不懂
共享共进共赢Sharing And Win-win Results
langzpin

主题

0

回帖

1

积分

新手上路

积分
1
贡献
在线时间
小时
2007-12-22 23:40:33 | 显示全部楼层

1.空字符串和 Null 不同 ,可能造成。(oracle 中 Null和'' 是有区别的)

2. 行不唯一,一笔资料对应多行。Sql 错误。

3.该资料被他人修改。

共享共进共赢Sharing And Win-win Results
dickpan

主题

0

回帖

5

积分

新手上路

积分
5
贡献
在线时间
小时
2008-8-7 11:21:52 | 显示全部楼层
在更新属性中,使用Key Columns解决这个问题,但是带来的后果就是数据只能保存最后一个人的更新。在多人共享的情况下会导致问题。
共享共进共赢Sharing And Win-win Results
您需要登录后才可以回帖 登录 | 站点注册

本版积分规则

免责声明:
本站所发布的一切破解补丁、注册机和注册信息及软件的解密分析文章仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。本站信息来自网络,版权争议与本站无关。您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。如有侵权请邮件与我们联系处理。

Mail To:Admin@SybaseBbs.com

QQ|Archiver|PowerBuilder(PB)BBS社区 ( 鲁ICP备2021027222号-1 )

GMT+8, 2024-11-22 12:54 , Processed in 0.039981 second(s), 10 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表