Page 1 of 1

Retrieving updated TDataSet data in a background thread

Posted: Mon 22 Jun 2020 08:07
by Fabrice
Hello,


I'am testing multithreading with IBDac. For the moment the solution I have found is :
1) Execute a TIbcquery in a thread
2) Copy the result of 1) into a Memory Dataset (in the main thread) when 1) finished.

I would like to know if it possible to do something like Firedac :
https://delphi.programmingpedia.net/en/ ... und-thread
or
https://riptutorial.com/fr/delphi/examp ... le-firedac


The very interesting to transfer data between Query is the property :

Code: Select all

 Form.FDQuery1.Data := Query.Data;

Re: Retrieving updated TDataSet data in a background thread

Posted: Thu 25 Jun 2020 11:08
by oleg0k
Hello,

Our components don't have such functionality.
You are welcome to leave a feature suggestion on our UserVoice page ( https://devart.uservoice.com/forums/104 ... y_id=18939 ). If your suggestion receives many upvotes, we'll implement it.

wbr, Oleg
Devart Team

Re: Retrieving updated TDataSet data in a background thread

Posted: Thu 02 Jul 2020 08:08
by Fabrice
Hello oleg0k,

Thank you for answer : I have added my suggestion !

Re: Retrieving updated TDataSet data in a background thread

Posted: Tue 11 Aug 2020 14:18
by frickler
You cannot transfer from query to query, but from query to virtual dataset using Assign.

Re: Retrieving updated TDataSet data in a background thread

Posted: Mon 14 Sep 2020 22:49
by costasd
I do it differently. First of all, I presume that the reason to execute a Query in a thread is to keep the application responsive during long running queries, which often return large amounts of data. Therefore, copying the data from one DataSet to another is a bit inefficient, time wise and memory wise.

I define the query in the main thread but execute it in a background thread. There is no problem in doing this as long as your application does not "bother" the Query while it is executing in a thread. For example, don't call Query.Close in the main thread while the background thread is executing, you will probably create some havoc. It works perfectly for me and allows me to interrupt the query if it takes too long and also update the user on the fetch status (when fetching of data starts).

I must say that I am using TUniQuery for my purposes but I am fairly confident it works with TIBCQuery as well.

Let me know if you need an example.

Re: Retrieving updated TDataSet data in a background thread

Posted: Wed 23 Sep 2020 09:13
by oleg0k
Hello,
You can assign a TIBCQuery object to a TVirtualTable object, for example: VirtualTable.Assign(IBCQuery);
See the VirtualDAC documentation for information on populating TVirtualTable with data from TDataSet: https://www.devart.com/virtualdac/docs/ ... bject).htm
Notice that TVirtualDataSet doesn't store data in memory and interacts with data using event handlers. It can be used to represent of arbitrary data (arrays, lists etc.) in tabular form, for example, to visualize data using data-aware controls.
More information on TVirtualDataSet: https://www.devart.com/virtualdac/docs ... ataset.htm

wbr, Oleg
Devart Team