doug at artsman.com
Mon Nov 28 15:09:45 UTC 2022
sql workers have a couple of genre’s to them
as I recall, you can have
‘fire and forget’ — where you don’t care about the result
’something that returns a result on a timer’ — where you care about the result.
Fire and forget — maybe you update something and don’t really care to know if it works.
we do that for saving window positions, headed list columns, sort orders, etc — . I wnat it to work, but if somebodies saved position doesn’t get saved, it is not the end of the world.
so to do that.. make a sql worker object (I”m using postgres) and set these two properties.
# Default to fire and forget since that is what we want most
Calculate $cinst.$cancelifrunning as kFalse
Calculate $cinst.$waitforcomplete as kFalse
result — stuff as many sql statements as you want at the sql worker and it will do them concurrently.
caveat — you won’t know the result.
’something that returns a result on a timer’
if you want the result back, and you are trying to do simultaneous requests, then you need sql worker instance for each result you are sending off.
we do this when
- we have a sub window that has a headed list that is bound to a table class.
- I need to fill that list with some data from the database
- each sub window has its own instantiate sql backround worker.
and if I have multiple of these sub windows, say one in each tab pane on my window…. I can tell each sub window to load itself with data at the same time.
that causes multiple sql object worker instances (one within each subwindow) to start more or less simultaneously and each will call back to its own sub window ‘completion’ method .. and fill the lsit with data.
Arts Management Systems Ltd.
mailto:doug at artsman.com
Phone (403) 650-1978
> On Nov 28, 2022, at 1:28 AM, Phil (OmnisList) <phil at pgpotter.co.uk> wrote:
> Hi Das,
> If you do a loop to init a single worker, it will probably reset after the first one...
> you can re use it, but only after it completes its first operation.
> ie a normal loop is not a way to do it.
> If you have a number of known sql commands it can run a whole list of SQL commands, and when they are all complete, it will return any results all together, for you to decipher after the event.
> The Omnis Samples have one for SQL Worker Objects showing this...
> Documents online might explain better:
> But basically, for a worker, you go ask it to do a job, and then forget it, assume it won't be available whilst you continue the rest of the current method...
> You could ask that one worker to do a number of SQL commands, if that fits your purpose, or if not, then you need multiple worker objects.
> Phil Potter
> Based in Chester in the UK.
> On 27/11/2022 18:10, Das Goravani wrote:
>> I’m using Studio 10.1 on this.
>> What is the correct way to fire off a bunch of SQL Workers?
>> Do you have one worker object or object ref, and then in a repeat loop you use that one over and over?
>> Or do you make a new one for each iteration of your loop?
>> I am new to the SQL Worker.
>> I have it so far working for the first firing.. it completes, but the second one dives into an not(lbOK) catch after the $init method as if something is wrong with using the object twice in a row.
>> Das Goravani
>> Ps: Hope you had a good holiday!
>> Manage your list subscriptions athttps://lists.omnis-dev.com
>> Start a new message ->mailto:omnisdev-en at lists.omnis-dev.com
> 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