Canceling query execution

Discussion forum about all things SqlBase or SqlTalk
kamil.wieszczycki
Poland
Posts: 6
Joined: 28 Mar 2022, 11:19
Location: Poland

Canceling query execution

Post by kamil.wieszczycki » 14 May 2022, 20:27

What is the recommended way to cancel long running queries?

RainerE
Germany
Posts: 2261
Joined: 27 Apr 2021, 12:40
Location: Germany

Re: Canceling query execution

Post by RainerE » 16 May 2022, 12:29

I don't know a way to cancel the execution of a query (SqlPrepareAndExecute() or SqlExecute()).

But you can cancel the SqlFetchNext() loop.

Up to TD 4.2 we enabled message yielding for the whole form window while looping through the records.
Starting with TD 7.4.1 we had to enable message yielding for the internal parent of the form windows (which is something between the title bar of the form window and its contents).
We have a push button pbCancel. If you click this button, the window variable w_bCancel is set to TRUE.
We do only continue the loop, if w_bCancel is FALSE.
Don't forgett to disable message yielding after this.

TD 4.2 code:

Code: Select all

Set w_bCancel = FALSE
Call SalYieldStartMessages( hWndForm )
While not w_bCancel and SqlFetchNext()
  ! display the record
Call SalYieldStopMessages()
TD 7.4.1 code:

Code: Select all

Set w_bCancel = FALSE
Call SalYieldStartMessages( GetParent( hWndForm ) )
While not w_bCancel and SqlFetchNext()
  ! display the record
Call SalYieldStopMessages()
GetParent() is an external function from USER32.DLL which is declared as follows

Code: Select all

Library name: USER32.DLL
    Function: GetParent
	Description:
	Export Ordinal: 0
	Returns
		Window Handle: HWND
	Parameters
		Window Handle: HWND
Regards,
Rainer

Return to “SqlBase General Discussion”

Who is online

Users browsing this forum: [Ccbot] and 1 guest