Sv: $update only for row

Daniel Sananes daniel.s at
Tue Mar 14 05:46:02 UTC 2023

Hi Doug
This is as far as I have come up till now. There are a lot left. But as I said before I need to do the study as precise as I possibly can. 

I took the challenge to determine what has changed.
First using the HistoryList approach and then to skip the HistoryList as I think, for now, that it is just a copy of a list.
And I can make a copy myself.

Of course $smartlist() is smart, but as I see it you can program it even smarter. I think, I am not sure.
So far I have not implemented anything that would update several lines in a list.
And also I have not started with Querys which involves more than one schema. This will be an interesting one!

At this point in $construct I build a list of users (or articles or clients) that are presented in a list to the left in my window.
  Do $tables.tTable.$sqlclassname.$assign('s_user') Returns #F
  Do iUserList.$definefromsqlclass('tTable') Returns #F
I use, for now, only one Table in my program. Have to find out why one might need several tables.
This one and only Table takes care of Users, Articles and Clients. Yes, I now have 3 schemas with corresponding postgres tables.

The most important class must be the schema as it is the schema that views the table in the postgres database.
I even wonder what help Tables really do?
I mean, the code in my overridden $update could be placed somewhere else.

A click on a line makes the edit-button active and shows the values for that line.
Click on the edit-button and the fields can be entered for inserting new values. The list is temporarily disabled.
The fields have names like iUserList.user_id or iUserList.user_name.
This is a bit different from how I used to program in Omnis7.
Here it seems one is entering values directly in to the list. Fields and the list are the same so to speak.

A copy of the list is created with Calculate lOldList as iUserList.
If cancel is pressed iUserList is calculated as lOldList.
If iUserList was a smartlist one could have used Do iUserList.$revertlistupdates().

Now I change the values in some of the fields but not all of them.

Click on Ok runs this code:
  Do iUserList.$update(lOldList) Returns lReturn

lOldList is received in the table's $update as a row-parameter. A passed list becomes a row with the correct line.
The first thing in the $update is to check what has changed and only put those fields in the updatenames.
The method constructs a string like $updatenames would do but only for fields that has changed.

  Do method SetUpdateString (pOldRow) Returns lStringUpdateFields
  If len(lStringUpdateFields)=0
    Quit method
  End If
  Calculate lStringUpdateFields as con(' SET ',lStringUpdateFields)

***Method SetUpdateString***
#Note that fields in the list not present in the schema is omitted.
#Also note that I do not know at this moment what to do if the list contains fields from several schemas.
#And I don’t know if a binary or picture field can be tested with OldValue<>NewValue.

Calculate lColCount as $cinst.$colcount
Calculate lRow as $cinst  ##$cinst is a list but the current line is put in lRow.
For lStep from 1 to lColCount
  If pOldRow.[lStep]<>lRow.[lStep] ## change
    Calculate lColName as lRow.$cols.[lStep].$name
    Do $schemas.[iSchemaName].$objs.$findname(lColName) Returns #F
    If flag true
      Calculate lColValue as con('@[$cinst.',lColName,']')
      Calculate lColName as con('"',lColName,'"')
      Calculate lSubString as con(lColName,'=',lColValue)
      Calculate lString as con(lString,lSubString,',')
    End If
  End If
End For
Calculate lString as mid(lString,1,len(lString)-1)
Quit method lString


-----Ursprungligt meddelande-----
Från: omnisdev-en <omnisdev-en-bounces at> För Doug Easterbrook via omnisdev-en
Skickat: den 13 mars 2023 00:49
Till: OmnisDev List - English <omnisdev-en at>
Kopia: Doug Easterbrook <doug at>
Ämne: Re: $update only for row

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


and the current value that was last changed


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
Phone (403) 650-1978

> On Mar 12, 2023, at 1:34 PM, Daniel Sananes <daniel.s at> 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 Start a 
> new message -> mailto:omnisdev-en at

Manage your list subscriptions at Start a new message -> mailto:omnisdev-en at
VARNING: Det här e-postmeddelandet kommer från en extern avsändare. KLICKA INTE på länkar eller bilagor om du inte känner igen avsändaren och vet att innehållet är säkert.

More information about the omnisdev-en mailing list