Hello
I have a problem here and I am not sure what am I doing wrong.
I have a main form, and a thread that does some data updates.
When I press a button on the main form a new thread starts. It creates a new connection to mysql server and a new query. First I am opening the records I need to check. This may take quite a long time, from 10s to 1-2 min. I want when I close the main form the opening of the records to break, the connection to close and the thread to terminate.
This sounded very easy since TCustomDADataSet has a nice method Executing and TCustomMyDataSet has a nice method BreakExec.
But I found out the following:
- even if the query is executing at the moment Executing returns False !!!
- even if I call BreakExec query execution does not break !!!
Both are called from the main thread.
I have solved this by creating my own boolean variable and by creating my own mechanism for killing thread. But I would like to use MyDAC functionality. Maybe I am doing sth wrong, or there is a bug somewhere.
I would appreciate very much your advice. Thank you
About BreakExec and Executing
Re: About BreakExec and Executing
The Executing property equals to True only during an SQL statement is executed. Check the Fetching property to learn whether TCustomDADataSet is still fetching rows.GuzunNicolae wrote:- even if the query is executing at the moment Executing returns False !!!
We have reproduced this problem and fixed it. This fix will be included in the next MyDAC build.GuzunNicolae wrote:- even if I call BreakExec query execution does not break !!!
However, as a solution you also can use the TCustomDADataSet.FetchAll property. You can find more detailed information about this property in the MyDAC help.
-
GuzunNicolae
- Posts: 78
- Joined: Wed 17 Jan 2007 14:16
Re: About BreakExec and Executing
Yes I indeed use FetchAll = False. But the dataset I guess did not start to fetch rows yet. I have Options.QueryRecCount=True. So I guess that the query to count the rows delays the execution. Thus, as I undestand, neither Executing neither Fetching will be true. Is this correct ?Dimon wrote:The Executing property equals to True only during an SQL statement is executed. Check the Fetching property to learn whether TCustomDADataSet is still fetching rows.GuzunNicolae wrote:- even if the query is executing at the moment Executing returns False !!!
You mean to use FetchAll = True ? Or to False ? I cannot use FetchAll=True since the records I am going to check can be millions. I even use UniDirectional=True to consume less memoryDimon wrote:We have reproduced this problem and fixed it. This fix will be included in the next MyDAC build.GuzunNicolae wrote:- even if I call BreakExec query execution does not break !!!
However, as a solution you also can use the TCustomDADataSet.FetchAll property. You can find more detailed information about this property in the MyDAC help.
Re: About BreakExec and Executing
Yes, you undestand rightly - neither Executing neither Fetching will be true.GuzunNicolae wrote:I have Options.QueryRecCount=True. So I guess that the query to count the rows delays the execution. Thus, as I undestand, neither Executing neither Fetching will be true. Is this correct ?
I meant FetchAll=False mode. At that TMyQuery.Open return control at once after fetching number of rows, specified in FetchRows.GuzunNicolae wrote:You mean to use FetchAll = True ? Or to False ?
And after this you can call Close to stop working with TMyQuery.
-
GuzunNicolae
- Posts: 78
- Joined: Wed 17 Jan 2007 14:16
Re: About BreakExec and Executing
So to summarize.
In my situation (lots of records, FetchAll=False, Options.QueryRecCount=True) after I call Open and it counts the recs, I have no way to know that the query is executing. Right?
The problem is that my delay comes from counting rows.
In my situation (lots of records, FetchAll=False, Options.QueryRecCount=True) after I call Open and it counts the recs, I have no way to know that the query is executing. Right?
This method will not really help me, since I am already using FetchAll=False now.Dimon wrote:I meant FetchAll=False mode. At that TMyQuery.Open return control at once after fetching number of rows, specified in FetchRows. And after this you can call Close to stop working with TMyQuery.
The problem is that my delay comes from counting rows.