But to do this you can run into trouble. If you have not a database transaction outside the insertation and manipulation, other users can modify your record as well. And as soon you want to do your update() or doUpdate() you get an exception:
Cannot edit a record in Table (Tablename).
An update conflict occurred due to another user process deleting the record or changing one or more fields in the record.
Therefore avoid such code:
Table table; ; table.KeyField = 'a'; table.insert(); table.AdditionalField = 'halli galli'; table.update();
Do it that way instead:
Table table; ; ttsbegin; table.KeyField = 'a'; table.insert(); table.AdditionalField = 'halli galli'; table.update(); ttscommit;
Or even this way:
Table table; ; table.KeyField = 'a'; table.insert(); // time consuming other code here ttsbegin; table.selectForUpdate(true); table.reread(); table.AdditionalField = 'halli galli'; table.update(); ttscommit;
Depending on requirements you may need a database transaction over all code or not.
It really solved my problem!
ReplyDeleteThanks a lot! Solved mine too!
ReplyDeleteHi,
ReplyDeletehow I could know which class I should update ?
I had prolem when print fixed aseet journal.
Thank you