Home » Developer & Programmer » Forms » Locking to win last update ? (Forms 6.0.8)
Locking to win last update ? [message #656001] Mon, 19 September 2016 13:07 Go to next message
bluetooth420
Messages: 146
Registered: November 2011
Senior Member
Hi,

My problem is as follow:

In two different oracle forms sessions working on same table(s).

Session #1 reads the row "Joe Bloggs".
Session #2 reads the row "Joe Bloggs".
Session #2 changes the row to "Jane Bloggs" and saves.
now, Session #1 is still looking at "Joe Bloggs" on their screen.
Session #1 changes the row to "Joe Jones" and saves.



But the updation of session #1 is lost.
I want "last update wins".


Tried to study execute_query(for_update) but it stops session 2 and even does not allow session 3 in my multi user/session environment.

Kindly guide.

Just an additional point: Session 2 is using

FORMS_DDL(update table set column='Jane Bloggs');
FORMS_DDL('COMMIT');


while session 1 is using data entry form in execute_query mode.
Re: Locking to win last update ? [message #656004 is a reply to message #656001] Mon, 19 September 2016 15:07 Go to previous messageGo to next message
Littlefoot
Messages: 21806
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Generally speaking, Forms takes care about such things itself. I'd expect it - in your session #1 - to report FRM-40654 record has been updated. Requery the block to see the change (or whatever the exact message is) as soon as you try to save the "Joe Jones" value. It means that you'd first have to requery that block, see "Jane" (instead of "Joe"), update it to "Joe Jones" and - finally - save it. Therefore, you'd get what you want, i.e. that the last update wins.

I don't know whether FORMS_DDL affects it; I *guess* not (why would it matter; the record has been changed, after all). Maybe it has something to do with "DML returning value" and/or "Key mode" properties ...

Hopefully, someone else will know better.
Re: Locking to win last update ? [message #656013 is a reply to message #656004] Tue, 20 September 2016 03:30 Go to previous messageGo to next message
cookiemonster
Messages: 13917
Registered: September 2008
Location: Rainy Manchester
Senior Member
Last update always wins unless it errors out.
By default forms will lock a row in the DB as soon as you start editing it in the datablock.
And as LF says if you try to save changes to a row that's been updated by someone else you'll get a forms error.
Have you got an on-error trigger that's masking errors?
Re: Locking to win last update ? [message #656015 is a reply to message #656013] Tue, 20 September 2016 05:54 Go to previous message
bluetooth420
Messages: 146
Registered: November 2011
Senior Member
On-error trigger has not raised/caught any error.

I have solved the problem other way.

Before execute_query in session 1, i riased a flag on the record on which i was about to work.
Due to raised flag, session 2 was NOT looking this record as i have added FLAG='N' in where clause. So session 2 was not looking the record.
LAter, at end of working in session 1, after committing form, i raised the flag down. Now session 2 module can see the record.

Flag system was not there when i posted my problem but anyhow i managed to solve it as i can bear to ignore FLAGGED records in session 2.


Thanks LF and CM for your time. I really appreciate it
Previous Topic: To erase value when cursor leaves the field
Next Topic: how to giv give auto path in forms buttons?
Goto Forum:
  


Current Time: Fri Mar 29 03:27:41 CDT 2024