How to run background DB process on server?

Hi,

In response to this question: http://connect.remobjects.com/discussion/1149/advice-needed-on-multi-threaded-datatable-updates - @slavad mentioned using Async connections from the client (which is working well). However, I would really like to know what is the recommended method of running a background update that is started from the server, not the client. Note that I don’t need to wait for a response, any problems could be logged to the database.

I have a set of OLAP tables that need updating from the OLTP tables after data is updated on the server. Seems to me that the obvious way would be to run a method from within the TDABusinessProcessor.OnAfterProcessDelta (OnAfterProcessChange?) event. But I would need it to run in background and not hold up the client app, so can you give me an idea how to do this? (NB: I’m a complete newbie on threading issues)

For info, the OLAP update procedure uses TDALocalDataAdapter and the first thing it does is DALocalDataAdapter1.ServiceInstance := self;

Thanks in advance,

Stuart

Stuart,

Instead of using the standard TThread included in Delphi, I created a new inherited class for several event-controlled threads (like a thread activated by a timer, or a thread acting like a consumer which will activate only when there is something available to consume).
In this particular case, you could create a thread which will wait for some event (once the data is updated in the database, you will do a Event.SetEvent) and in each activation it will take care of the process required for taking information between OLTP and OLAP.
It is the equivalent of using a trigger on the database just for scheduling a task which later will process the data in the database engine.
Of course, by using a different thread for this processing, the call from your clients won’t be delayed.
If you need some threading code / classes, I can send it to you by e-mail.

David

You can’t go wrong with http://andy.jgknet.de/blog/bugfix-units/asynccalls-29-asynchronous-function-calls/ or much better:http://otl.17slon.com/

@David - thanks (again :wink: for your reply. I always seem to learn better with code samples and I would like to take you up on your kind offer :slight_smile: My email is my connect username@gmail.com

@mamcx - thanks for those links, I will look into those. Seems I need to learn much more about threading in general.