Override $doupdate() for a smart list --> I think you want to override $update
Doug Easterbrook
doug at artsman.com
Sun May 30 03:25:49 UTC 2021
hi Gord.
you want to override $update. (not $doUpdates —— thats what does a set of updates).
$update has a row parameter … which is the old row
that way you can compare oldrow.myfield to $cinst.myfield (i.e. old row to new values) if you need to.
we do a lot in our $update including fabricating our own SQL to only update fields that change. thats a different topic. Happy to share that code if you want.
in your case, Jim pistrang gave you the hint. effectively your $update might look like
$update()
calculate $cinst.TimeStampField as #D
calculate $cinst.UserFIeld as ’someUserSeq’
Do default
the do default tells omnis to finish off the update process for you …. you just pre-emptively, set some variables and let omnis finish it of.
then to get the updates to happen, you just invoke the $dowork of the sql list
$doWork determines when to call the various $insert/$update/$delete methods.
this is the gist. there is much more you can do…. but as I said, another topic for another time.
Doug Easterbrook
Arts Management Systems Ltd.
mailto:doug at artsman.com
http://www.artsman.com
Phone (403) 650-1978
> On May 29, 2021, at 2:12 PM, Gordon Wilson via omnisdev-en <omnisdev-en at lists.omnis-dev.com> wrote:
>
> Hi @All
>
> I am trying to understand the Omnis way of doing SQL. I have a customer using my first implementation being an update of an existing customer's Omnis system and have been delighted (mostly) with the many benefits over using the Omnis standard data file.
>
>
> In all of this, I have used the methodology developed by Das Giovani with the exception of one window I have added as an addition to the old program. This window uses a smart list based on class wizard. In this case I have Groups as a parent and Stock as a child. Groups are simply stock categories.
>
> Editing stock using a window that accesses one stock record at a time, I can override the $update method to include a timestamp and user just like Jim Pistrang does in his video on Youtube.
>
> My question is, how is this done by overriding $doupdate or $doupdates for a smartlist?
>
> From the manual I see this... (Note the last sentence)
>
>
>
> $updatenames()
> Do MyRow.$updatenames() Returns UPDATETEXT
>
> Returns a text string in the format: SET TABLE.col1=@[$cinst.col1],TABLE.col2=@[$cinst.col2],
> TABLE.col3=@[$cinst.col3],...,TABLE.colN=@[$cinst.colN]
>
> where col1...coln are the server column names of the columns in the row variable. Eachcolumn name is qualified with the name of the server table. Do MyRow.$updatenames([old_name]) Returns UPDATETEXT
>
> The optional parameter old_name is the name of a row variable to be used to generate a ̳where‘ clause. If you include old_name, a ̳where‘ clause is concatenated to the returnedstring in the following format: WHERE col1=@[old_name.col1] AND ... AND colN=@[old_name.colN]
>
> The columns in the where clause depend on the setting of $useprimarykeys. If$useprimarykeys is kTrue, then the columns in the where clause are those columns markedas primary keys in their schema class. Otherwise, the columns in the where clause are allnon-calculated columns except those with data type picture, list, row, binary or object.
>
> You can replace $cinst in the returned string using: Do MyRow.$updatenames([old_name][,row_name]) Returns UPDATETEXT
>
> where row_name is the name of row variable which Omnis uses in the bind variables. Thismay be useful if you override $doupdate() for a smart list.
>
> This is a clue but I have no idea how to do this.
>
> Any advice here would be much appreciated.
>
> Kind regards, Gordon.
>
> _____________________________________________________________
> 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