Update Problem Resolved

Doug Easterbrook doug at artsman.com
Sun Aug 16 14:27:38 EDT 2020


hi rudolf.

You asked a question - so if you don’t mind, I’d like to take it in a philosophical direction.  

what you say is true — and it made me think of what we’ve done in our table superclass for $dowork() — because we didn’t do that.   and since our superclass was written some 15 years back, it made me pause and think.

in the $doWork, for the update case, we explicitly do two things
calculate the old row as the history list
pass that in to $update

eg below.

Calculate iRowOld as $cinst.$history.[$cinst.$line].$oldcontents

Do $cinst.$update(iRowOld)

I got to thinking why on earth would we do that.

and then it dawned on me, if you pass in an explicit history list, one of the benefits is that you can write code a bit easier to deal with change in contents

eg

within $update, you can call any method you want (we have $preUpdate, $postUdpate, $setStandardDateFields, and a few others)

and 
$cinst — is always the new values
iRowold is always the old values

and you can do things like pre and post update triggers which might be easier to read

if $cinst.Field<>irowOld.Field
  do some centralized changes for field change within the table class
end if

 

instead of 

if $cinst.Field<>$cinst.history.[$cinst.$line.$oldcontents.Field
  do some centralized changes for field change within the table class
end if


just found it made things easier to read and debug in omnis. checking values in the history list (to my recollection), is a bit difficult.





Doug Easterbrook
Arts Management Systems Ltd.
mailto:doug at artsman.com
http://www.artsman.com
Phone (403) 650-1978

> On August 16, 2020, at 8:45 AM, Rudolf Bargholz <rudolf at bargholz.ch> wrote:
> 
> Hi Das,
> 
> Would not
> 
> Do $cinst.$update($cinst) work as well, as long as your table class instance has the primary key column filled?
> 
> Regards
> 
> Rudolf Bargholz
> 
> -----Ursprüngliche Nachricht-----
> Von: omnisdev-en [mailto:omnisdev-en-bounces at lists.omnis-dev.com] Im Auftrag von Das Goravani
> Gesendet: Samstag, 15. August 2020 00:55
> An: OmnisDev List - English <omnisdev-en at lists.omnis-dev.com>
> Betreff: Update Problem Resolved
> 
> 
> US Tech Support sorted out my update problem.
> 
> It turns out that it matters that you pass a real row in the old_row space and not a name in square brackets.. 
> 
> Just calculate a row as that name and pass the row, ie:
> 
> Calculate iUpdateRow as [iOldRowName]
> Do $cinst.$update(iUpdateRow)
> 
> I don’t know why this simple fix evaded me so long except to say I aint what I used to be.. age seems to be taking it’s toll on mental powers. 
> 
> I’m glad that I can Update now and I have to pass the credit to US Tech Support for figuring out my dilemma.
> 
> In the end this is so simple.. but if you never try that approach then you never hit it.. but I can’t believe it was this simple. 
> 
> Embarrassed. 
> 
> 
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 
> _____________________________________________________________
> Manage your list subscriptions at http://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com 




More information about the omnisdev-en mailing list