$update only for row
Doug Easterbrook
doug at artsman.com
Sun Mar 12 23:48:51 UTC 2023
hi Daniel
when you are updating , there are two things available to you
- the OLD_ROW -and-
- the current row.
thats because the V3 dams and smart lists in Studio track what the row was before you changed anything. you can get those old values winthin any window or any code referring to a field in the list as
list.$history.[list.$Line].$oldcontents.MyField
and the current value that was last changed
list.[list.$Line].MyField
Studio uses these automatically for you to determine if a row in a list is changed, inserted or deleted. There is far more to this that my simple explanation.
by, suffice to say, you ALWAYS can check the value of a row before any changes occurred and after changes have been made at any time. … which the list is $smartlIst =Ktrue
SO, to make it easy for you in $UPDATE you call is as
do $update(Old_Row)
or to make it explicit for you, you can determine the old row (i called it iRowOld ) as below where the old row contains the history before updates.
Calculate iRowOld as $cinst.$history.[$cinst.$line].$oldcontents
Do $cinst.$update(iRowOld)
this is very convenient, because in the $update routine, you can do things like
if OLD_ROW.MyField<>$cinst.MyField
Breakpoint: this field changed
end if.
or, if you want to minimize the amount of data transferred, the implication is that you can check each column to see if the column was changed, and only include changed columns in the update routine (we do that … why send a large binary image if it hasn’t changed).
Recap of the story
this is how you set the old row in $dowork (of if you don’t over ride it, omnis does it for you.
Calculate iRowOld as $cinst.$history.[$cinst.$line].$oldcontents
Do $cinst.$update(iRowOld)
so that in $update, old_Row parameter is the data before th upadte so you can make intelligent decisions about some part of the update (like ignore unchanged data)
hope that helps.
Doug Easterbrook
Arts Management Systems Ltd.
mailto:doug at artsman.com
http://www.artsman.com
Phone (403) 650-1978
> On Mar 12, 2023, at 1:34 PM, Daniel Sananes <daniel.s at kopparbergs.se> wrote:
>
> Hi
>
>
>
> The online doc says that only row variable can use $update.
>
> It says:
>
> $update(old_row)
>
> updates a row in the server database (row variables only)
>
>
>
> But I am using:
>
> Do iUserList.$update() Returns #F
>
> Even if the $update part is not shown when I type the $ when entering this code.
>
> It goes to my overridden method and works.
>
>
>
> Why does one say it does not work on lists?
>
> And what about the old_row in $update(old_row)? It works without this.
>
>
>
> Strange I think.
>
>
>
> Regards
>
> Daniel
>
>
> /Daniel
> 0736 704070
>
> _____________________________________________________________
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
More information about the omnisdev-en
mailing list