Page 1 of 1

Lock/deadlock and threads

Posted: Thu 04 Oct 2007 13:18
by Gaby23
Hello,

I'm using Borland Delphi 2006 and ODAC 6.20 (I tried ODAC 5.80).

I created Threads to run SQL commands, because the application needs to dialog with the second database even if the first wait the answer from the database.

I use ExecSQL procedure from TCustomOraQuery to execute the queries.

It's works, but when the database is in Lock/deadlock mode, the ExecSQL wait.
If there are a unlock, the command is executed and the thread normaly terminated.
If there are a network problem, the thread still run infinitly.

If I kill the Thread like "TerminateThread(ThreadOracle.Handle, 0);", The thread is terminated but when I recreate the Thread (after the unlock of the database) the ExecSQL still waiting...
Perhaps there are a link not terminated with the ODAC.

What's the solution to terminate the Thread properly or detect and stop ExecSQL ?

Thank you in advance,
Gaby

Posted: Thu 04 Oct 2007 14:51
by Plash
Try to call the BreakExec method of TOraQuery to stop the query execution.

Posted: Thu 04 Oct 2007 15:34
by Gaby23
Thank you for the answer.

I tried a BreakExec but it seems did nothing.
I tried a BreakExec and kill the thread but it's the same, the ExecSQL still waiting (database is unlocked)...

Gaby.

Posted: Fri 05 Oct 2007 07:38
by Plash
There is no other way to stop execution except the BreakExec method.

Posted: Fri 05 Oct 2007 08:41
by Gaby23
Hello,

There are NonBlocking mode, but if NonBlocking := true ExecSQL don't block.
Is it possible to read ExecSQL state, and perhaps kill ExecSQL using BreakExec if ExecSQL still executing? (.Executing return allways True)

Thank you in advance,
Gaby

Posted: Mon 08 Oct 2007 09:03
by Plash
In NonBlocking mode a query execution can be stopped by calling the BreakExec method. But if the BreakExec method cannot stop the execution when you have started it from a separate thread, this method also will not help in NonBlocking mode.