Page 1 of 1

About BreakExec and Executing

Posted: Tue 11 Dec 2007 10:08
by GuzunNicolae
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

Re: About BreakExec and Executing

Posted: Fri 14 Dec 2007 09:04
by Dimon
GuzunNicolae wrote:- even if the query is executing at the moment Executing returns False !!!
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 I call BreakExec query execution does not break !!!
We have reproduced this problem and fixed it. This fix will be included in the next MyDAC build.
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

Posted: Sat 15 Dec 2007 14:36
by GuzunNicolae
Dimon wrote:
GuzunNicolae wrote:- even if the query is executing at the moment Executing returns False !!!
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.
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:
GuzunNicolae wrote:- even if I call BreakExec query execution does not break !!!
We have reproduced this problem and fixed it. This fix will be included in the next MyDAC build.
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.
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 memory

Re: About BreakExec and Executing

Posted: Mon 17 Dec 2007 14:41
by Dimon
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 ?
Yes, you undestand rightly - neither Executing neither Fetching will be true.
GuzunNicolae wrote:You mean to use FetchAll = True ? Or to False ?
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.

Re: About BreakExec and Executing

Posted: Mon 17 Dec 2007 15:42
by GuzunNicolae
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?
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.
This method will not really help me, since I am already using FetchAll=False now.
The problem is that my delay comes from counting rows.

Posted: Fri 21 Dec 2007 14:28
by Dimon
You are right. We will consider possibility to change the behavior of TMyQuery in this situation in the near future.