ABORT A LONG QUERY BEFORE IT FINISH 
Author Message
 ABORT A LONG QUERY BEFORE IT FINISH

Quote:

>Anybody knowns a easyway to stop a stop a query before it finished.
>It is very userful to terminate along query. but so far I can't think
>of any eay way to do it. I do think about that I could creat a new
>thread to run query and leave the interface active. also I try to do
>something
>about BDE API call back function. but I still think delphi should
>take care of it.

Ditto.  Looking for the same information.  I agree that in Delphi 2.0 one
could run a query on its' own thread in order to leave the interface active,
but what about Delphi 1.0.  I've looked in the documentation, I've tried
logical keystrokes, but have never found a way to do this.

--
Bob McClintock



Tue, 20 Apr 1999 03:00:00 GMT  
 ABORT A LONG QUERY BEFORE IT FINISH

Hi Bob,

Quote:

> Ditto.  Looking for the same information.  I agree that in Delphi 2.0 one
> could run a query on its' own thread in order to leave the interface active,
> but what about Delphi 1.0.  I've looked in the documentation, I've tried
> logical keystrokes, but have never found a way to do this.

Check out my reply to this thread - it works with both Delphi1 and 2.

Regards,

Rob
--
Rob McGillivray
Manager: Client/server Software Development
DataSoft - "Voted Top Development House in South Africa - 1994"
ODBCExpress: the top ODBC data access tool for Delphi, http://www.odbcexpress.com



Fri, 23 Apr 1999 03:00:00 GMT  
 ABORT A LONG QUERY BEFORE IT FINISH

Here's one simple situtation which I have implemented quite
successfully.  Due to the nature of my project I use TQuery
exclusively.  The nice thing about TQuery is that you can
open a it and then fetch each record individually
(using the Next method).  So you can just close the query
before you have fetched everything.

For example:

  var
    MyQuery : TQuery;

      [ ..... ]

    with MyQuery do begin
      Active := false;
      SQL.Clear;
      SQL.Add('YOUR SQL STATEMENTS');
      Active := true;
    end;

    while not MyQuery.EOF do begin
      (*  get the values of the current record here *)
      SomeField := MyQuery.Field[].Value .....;

      (*  then decide if you want to abort instead of continuing *)
      if SomeCondition then
        break
      else
        MyQuery.Next;
    end;
    MyQuery.Active := false;

    if SomeCondition then begin
       (* special processing if the query was canceled *)
    end;

N.B. instead of MyQuery.Active := true/false  you can use the
Open and Close methods, respectively.



Mon, 26 Apr 1999 03:00:00 GMT  
 ABORT A LONG QUERY BEFORE IT FINISH


Quote:
>Here's one simple situtation which I have implemented quite
>successfully.  Due to the nature of my project I use TQuery
>exclusively.  The nice thing about TQuery is that you can
>open a it and then fetch each record individually
>(using the Next method).  So you can just close the query
>before you have fetched everything.

>For example:

>  var
>    MyQuery : TQuery;

>      [ ..... ]

>    with MyQuery do begin
>      Active := false;
>      SQL.Clear;
>      SQL.Add('YOUR SQL STATEMENTS');
>      Active := true;
>    end;

>    while not MyQuery.EOF do begin
>      (*  get the values of the current record here *)
>      SomeField := MyQuery.Field[].Value .....;

>      (*  then decide if you want to abort instead of continuing *)
>      if SomeCondition then
>        break
>      else
>        MyQuery.Next;
>    end;
>    MyQuery.Active := false;

>    if SomeCondition then begin
>       (* special processing if the query was canceled *)
>    end;

>N.B. instead of MyQuery.Active := true/false  you can use the
>Open and Close methods, respectively.

This will certainly help if the length of the query is a product of a huge
result set.  But what about a query that requires an inordinate amount of time
to execute before any results are returned?  For example, if a user has a
dialog box and has entered information in order to shape the query and has
made a big mistake in doing so, shouldn't there be a way to cancel the
request?

--
Bob McClintock



Tue, 27 Apr 1999 03:00:00 GMT  
 ABORT A LONG QUERY BEFORE IT FINISH

Quote:

>This will certainly help if the length of the query is a product of a huge
>result set.  But what about a query that requires an inordinate amount of time
>to execute before any results are returned?  For example, if a user has a
>dialog box and has entered information in order to shape the query and has
>made a big mistake in doing so, shouldn't there be a way to cancel the
>request?

If there is (and I say "if" because I don't really know); chances are that
the "how to do it" a) would be server-dependent b) involve interacting
with the BDE directly.  The BDE calls are documented.  Somewhere in the
Borland site, I think.  Dunno about server capabilities, but if you
don't already know this stuff you'll have to spend a fair amount of
time looking it up, and you may find at the end of the day that
the server does not support this, and/or that the BDE gives you
no way of doing it.

In the example you give, probably the most practical thing
(rather than becoming a BDE guru) is to try to validate the user's
choices before submitting them as a query.



Tue, 27 Apr 1999 03:00:00 GMT  
 ABORT A LONG QUERY BEFORE IT FINISH


Quote:

>>This will certainly help if the length of the query is a product of a huge
>>result set.  But what about a query that requires an inordinate amount of time

>>to execute before any results are returned?  For example, if a user has a
>>dialog box and has entered information in order to shape the query and has
>>made a big mistake in doing so, shouldn't there be a way to cancel the
>>request?

>If there is (and I say "if" because I don't really know); chances are that
>the "how to do it" a) would be server-dependent b) involve interacting
>with the BDE directly.  The BDE calls are documented.  Somewhere in the
>Borland site, I think.  Dunno about server capabilities, but if you
>don't already know this stuff you'll have to spend a fair amount of
>time looking it up, and you may find at the end of the day that
>the server does not support this, and/or that the BDE gives you
>no way of doing it.

>In the example you give, probably the most practical thing
>(rather than becoming a BDE guru) is to try to validate the user's
>choices before submitting them as a query.

I would agree that it is to some degree server dependent.  However, ODBC
interfaces DO ALLOW you to break from a query to certain databases while I
have not found a way through BDE.  I work with databases that contain hundreds
of tables and often milions of rows of data.  Yes, there are some common sense
safeguards I can build into queries that the user can fire off by themselves,
but I know I will not prevent all long runaway queries.

I believe that ReportSmith does offer the ability to cancel a long running
query/report, but I guess that unless the data connection is set to use Delphi
it is not going through BDE.

--
Bob McClintock



Wed, 28 Apr 1999 03:00:00 GMT  
 ABORT A LONG QUERY BEFORE IT FINISH

Quote:


> >This will certainly help if the length of the query is a product of a huge
> >result set.  But what about a query that requires an inordinate amount of time
> >to execute before any results are returned?  For example, if a user has a
> >dialog box and has entered information in order to shape the query and has
> >made a big mistake in doing so, shouldn't there be a way to cancel the
> >request?

> If there is (and I say "if" because I don't really know); chances are that
> the "how to do it" a) would be server-dependent b) involve interacting
> with the BDE directly.  The BDE calls are documented.  Somewhere in the
> Borland site, I think.  Dunno about server capabilities, but if you
> don't already know this stuff you'll have to spend a fair amount of
> time looking it up, and you may find at the end of the day that
> the server does not support this, and/or that the BDE gives you
> no way of doing it.

> In the example you give, probably the most practical thing
> (rather than becoming a BDE guru) is to try to validate the user's
> choices before submitting them as a query.

Hi, out there !

Will DbiRegisterCallback do this job ? There are parameters to stop long
database operations. See the BDE helpfile for more information.

CU,

Juergen




Wed, 28 Apr 1999 03:00:00 GMT  
 ABORT A LONG QUERY BEFORE IT FINISH

Quote:



> >>This will certainly help if the length of the query is a product of a huge
> >>result set.  But what about a query that requires an inordinate amount of time

> >>to execute before any results are returned?  For example, if a user has a
> >>dialog box and has entered information in order to shape the query and has
> >>made a big mistake in doing so, shouldn't there be a way to cancel the
> >>request?

> >If there is (and I say "if" because I don't really know); chances are that
> >the "how to do it" a) would be server-dependent b) involve interacting
> >with the BDE directly.  The BDE calls are documented.  Somewhere in the
> >Borland site, I think.  Dunno about server capabilities, but if you
> >don't already know this stuff you'll have to spend a fair amount of
> >time looking it up, and you may find at the end of the day that
> >the server does not support this, and/or that the BDE gives you
> >no way of doing it.

> >In the example you give, probably the most practical thing
> >(rather than becoming a BDE guru) is to try to validate the user's
> >choices before submitting them as a query.

> I would agree that it is to some degree server dependent.  However, ODBC
> interfaces DO ALLOW you to break from a query to certain databases while I
> have not found a way through BDE.  I work with databases that contain hundreds
> of tables and often milions of rows of data.  Yes, there are some common sense
> safeguards I can build into queries that the user can fire off by themselves,
> but I know I will not prevent all long runaway queries.

In the BDE documentation you will find the DBICallBack mechanism. It
will let
you (among other things) have a call-back function that will be called
during
the execution of a long query. I have only experience with Paradox
tables.
The callback is called frequwntly enough to allow me to have a progress
bar
of the query. There is a flag you can return from the callback, but for
Paradox
tables at least the abort value is ignored, could be differently on
client/server
databases, though.

--
Hallvard Vassbotn



Fri, 30 Apr 1999 03:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. ABORT A LONG QUERY BEFORE IT FINISH

2. Operation Aborted (TQuery, SQL, Cached Updates) - Bit Long -

3. Aborting MS SQL queries

4. How do I abort a Query in Paradox?

5. Aborting select queries.

6. Aborting Queries

7. How to abort a query while executing ?

8. Help with long strings as query parameters

9. Long SQL queries

10. Long queries

11. Long queries and progress or SOMETHING...Geezzzzz...Can SOMEONE help me out here

12. Help w/ long query

 

 
Powered by phpBB® Forum Software