`
yinfeiL
  • 浏览: 4206 次
最近访客 更多访客>>
社区版块
存档分类
最新评论

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.

 

 

分享到:
评论

相关推荐

    PB并发控制与Row changed between retrieve and update详解

    PB并发控制与Row changed between retrieve and update详解 PB并发控制机制是指在多用户同时访问数据库时,防止数据不一致和丢失的机制。PowerBuilder 提供了多种并发控制策略,包括Key Columns、Key and ...

    RLUS:retrieve locate update service

    ### RLUS:Retrieve Locate Update Service 知识点详解 #### 一、RLUS概述 **RLUS(Retrieve Locate Update Service)**是Healthcare Services Specification Project (HSSP) 在OMG(Object Management Group)...

    Explorer for MySQL Data Base.You can retrieve and execute yo

    "You can retrieve and execute your query"进一步证实了这一点,它说明用户可以在这个工具中编写SQL查询并执行,获取所需的数据。 在描述中提到的"Explorer for MySQL Data Base"功能是允许用户检索和执行查询,这...

    Knowledge-driven Encode, Retrieve, Paraphrase for MedicalImageReport.pdf

    We propose a novel Knowledge-driven Encode, Retrieve, Paraphrase (KERP) approach which reconciles traditional knowledge- and retrieval-based methods with modern learning-based methods for accurate ...

    Professional ASP.NET 3.5 SP1 Edition: In C# and VB(part1)

    How to retrieve, update, and delete data quickly and logically using LINQ with side-by-side examples comparing LINQ to existing techniques * Ways to localize your web site in multiple languages ...

    Basic Save and Retrieve Functions

    标题 "Basic Save and Retrieve Functions" 暗示了这是一个关于在编程环境中保存和恢复数据的基础教程,可能涉及文件操作和程序状态的管理。在描述中没有提供更多的具体信息,但我们可以根据标签 "控件"、"源码"、...

    Query Retrieve SCP Emulator

    Query Retrieve SCP Emulator

    CoreDataSwiftDemo:带有Swift 4.2的CREATE,RETRIEVE,UPDATE和DELETE记录的基本数据

    这个名为"CoreDataSwiftDemo"的项目是基于Swift 4.2版本,旨在演示如何利用Core Data来实现CREATE(创建)、RETRIEVE(检索)、UPDATE(更新)和DELETE(删除)操作。下面我们将深入探讨这些核心功能以及如何在Swift...

    MyBatis-Generate

    MBG seeks to make a major impact on the large percentage of database operations that are simple CRUD (Create, Retrieve, Update, Delete). You will still need to hand code SQL and objects for join ...

    Delphi7.1 Update

    Delphi 7.1 Update Release Notes=======================================================This file contains important supplemental and late-breakinginformation that may not appear in the main ...

    Beginning JavaScript with DOM Scripting and Ajax: Second Editon

    How to access and update part of the page using code. How to use JavaScript to communicate with the server and retrieve data. How to use JavaScript to for form validation and user feedback. How to use...

    Unity Save Game Pro - Gold Update

    Save Game Pro has an Elegant and Complete API for controlling saved data, for example, by using the API you can check if a data exists or you can Retrieve the saved files list and show them to the ...

    Beginning JavaScript with DOM Scripting and Ajax (pdf + ePub)

    How to access and update part of the page using code. How to use JavaScript to communicate with the server and retrieve data. How to use JavaScript to for form validation and user feedback. How to use...

    Retrieve Web page or file (including all HTTP headers and me

    Retrieve Web page or file (including all HTTP headers and message body) througn HTTP protocol directly from VB program which utilize the MS WinSock Control.

    This demonstrates how to write and retrieve information from

    标题中的“write and retrieve information from”指的是在计算机的注册表中进行读写操作。注册表是Windows操作系统中存储系统和应用程序设置的关键数据库。通过修改注册表,用户或开发者可以精细控制系统的配置,...

    an introduction to information retrieve

    标题为“an introduction to information retrieve”的文档,实际上是指《信息检索导论》这本书的介绍。该书由斯坦福大学出版,作者包括 Christopher D. Manning、Prabhakar Raghavan 和 Hinrich Schütze。根据描述...

    retrieve_data.py

    retrieve_data

    艺术品管理系统的设计与实现 .doc

    2. **Artwork Information Management**: This module enables users to input, update, and retrieve detailed information about each artwork, including its title, artist, creation date, medium, provenance,...

Global site tag (gtag.js) - Google Analytics