Update Out of Sync

Darren Reely darren.reely@latticesemi.com
Wed, 13 Feb 2002 18:10:26 -0800


Hi All,

I have a screen that two users can update fields from different records.
Unfortunately we duplicate one of fields from the primary record to another
table, but this can fail when two users are in the screen performing
updates.

Here is the scenario.
  User 1 & 2 both pull up the same data at the same time.

  User 1 changes a value in the primary record.
  User 1 performs an update which does the 'put product_ms'.
  User 1 update performs postupdate procedure to copy the column
         to the other table.

  User 2 changes a value in a detail record.
  User 2 performs an update, which skips the 'put product_ms' since
         no fiels were changed for it.
  User 2 update performs postupdate with old value that user 1 changed.

  The columns are now out of sync.

Refer to code below if needed.

Now for my question.  Why when I've added 'NEED 1' to the primary record,
does the 'put product_ms' not get performed?  The proof is that the new
value is still in the record after the second user has updated his 'pmy'
record change.  I thought placing a NEED on a file statement forces an
update.  Am I misunderstanding this.  No errors or warnings are returned.

I think my solution will be to check if the field in the primary record has
changed. If so, only then do the update of the other table.  My other
solution is to use a trigger.


System is:
 PH 8.13.D1
 Sun Solaris 2.6
 Oracle Release 7.3.4.4.0.


file product_ms in mfg PRIMARY NEED 1
file product_ms_yield in mfg alias pmy DETAIL occurs 2 noitems
file tester_forecast_yield in mfg designer

procedure update
 begin
    put product_ms
    for pmy
        put pmy
end

procedure postupdate
begin
  while retrieving tester_forecast_yield via prod_line, ms &
       using prod_line, ms of product_ms
    begin
       let gross_die_waf of tester_forecast_yield = gross_die_waf of
product_ms
       put tester_forecast_yield
    end
end


Thank you for your time.

Darren

P.S.  The surprise is that this 5 year old bug (before my time) has only
thrown out 11 records total this year and last.  Also lucky, is the small
difference.