Easyest way to select data in a thread?

Discussion of open issues, suggestions and bugs regarding ODAC (Oracle Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Moehre
Posts: 42
Joined: Fri 11 Nov 2005 11:37

Easyest way to select data in a thread?

Post by Moehre » Fri 12 Oct 2007 07:12

Hello!

I read every thread about using THREADS and had a look at the Thread-Demo, but it seems to be much to complicated with all this pointer stuff.

Reading about threads I realized, that creating a thread in Delphi is simple (using "New" "Thread object"). Creating a new TOraSession and TOraQuery Object is no problem BUT: How can I access the data, that was selected in the TOraQuery Object created within the Thread? (Without any synchronizing problems) and how can I signal the main thread, that execution of the query is finished (using TEvent?). I think, that the TOraQuery object created in the thread would be killed when the thread is finished (using FreeOnTerminate)?

So, would you please be so kind to give a small, simple code example for selecting data in a thread?

The most easyest way for me would be an integrated function in TOraQuery like "TOraQuery.StartAsThread" property (boolean) and "TOraQuery.ThreadFinished" Event :)

Many thanks in advance

Plash
Devart Team
Posts: 2844
Joined: Wed 10 May 2006 07:09

Post by Plash » Fri 12 Oct 2007 10:18

TOraQuery has the NonBlocking property. If you set it to True, the TOraQuery component will create a thread to execute queries and fetch data. You can just link the TOraQuery component to TDataSource and TDBGrid. After a thread has finished executing and fetching, data will be displayed in the grid.

You also can use AfterExecute and AfterFetch events of TOraQuery.

Moehre
Posts: 42
Joined: Fri 11 Nov 2005 11:37

Post by Moehre » Fri 12 Oct 2007 14:38

Many thanks for this info! You should consider to change the thread demo program and replace this c#-multiple-pointer stuff with nonblocking query usage ... ;)

Grettings
Moehre

Post Reply