2

I have a Master Detail form in my apex application. Here is my Tabular Form Region Source.

select 
"ITEM_ID",
"ORDER_ID",
"QUANTITY",
"PRICE",
"NOTE",
wwv_flow_item.md5(QUANTITY) "item_hash" -- set to 'hidden' in tabular form
from "#OWNER#"."ITEMS"
where "ITEM_ID" = :P2_ITEM_ID

Also I have added Page Validation as below.

DECLARE
   l_error   VARCHAR2 (4000);
BEGIN   
   FOR i IN 1 .. apex_application.g_f02.COUNT
       LOOP

       IF apex_application.g_f06(i) IS NOT NULL AND
   wwv_flow_item.md5(apex_application.g_f03(i)) <> apex_application.g_f06(i)
        THEN    
           l_error := l_error    
            || '</br>'
            || '</br>'
            || 'Row '
            || i
            || '</br>'
            || '          Quantity Error';
         END IF;  

      END LOOP;
   RETURN LTRIM (l_error, '</br>');    
END;

But when I am trying to update data in this form, I am getting below error.

Current version of data in database has changed since user initiated update process. current row version identifier = "4E8A473F53865EF8720F14022DC71E03" application row version identifier = "0ABB3E73FB3E38844974E945864ECDED" (Row 1)

How can I solve this?

Bishan
  • 15,211
  • 52
  • 164
  • 258
  • Is any data actually being changed in the db? Do you have any javascript on the page which changes values, eg ajax to make updates or set value actions? – Tom Dec 03 '13 at 14:54
  • @Tom I have **AJAX Callback** to calculate `PRICE` when user change the `QUANTITY` in tabular form. but it is not changing the data in database. – Bishan Dec 04 '13 at 03:37
  • Does this happen every time, or only occasionally? This sounds like an optimistic locking problem. – Jon Heller Dec 04 '13 at 04:08
  • @jonearles only updating. not happen when creating an entry. – Bishan Dec 04 '13 at 04:59
  • I'd concur with @jonearles. This is optimistic locking, but I don't really see why it'd happen every time. The page validation is irrelevant even: there is no change to the arrays or db and it only checks submitted values. The issue is during the row processing, where apex detects a change of data. So that means the actual data has changed between render and submit, OR for some reason apex is not/cannot calculating the correct checksum. Does the error display any extra info? Anything extra when running in debug? Can you try to NOT use the md5 column (replace it with '0' just to test). – Tom Dec 04 '13 at 08:22

1 Answers1

-1

Try to name your hidden item as its Table Name field.

In example:

select 
"ITEM_ID",
"ORDER_ID",
QUANTITY as "QCT",
"PRICE",
"NOTE",
wwv_flow_item.md5(QUANTITY) "QUANTITY" -- set to 'hidden' in tabular form
from "#OWNER#"."ITEMS"
where "ITEM_ID" = :P2_ITEM_ID

The error says that before the update the column name has changed, and it did. You named it item_hash, as it differs from QUANTITY.

TLama
  • 75,147
  • 17
  • 214
  • 392