Hello,
i can't seem to be able to find an answer to a couple of scenarios regarding concurrent queries and multithreaded application.
1) A SELECT query is open and i want to execute another query (INSERT/UPDATE/DELETE) do i need to use a different TZConnection object? Of course i use different TZQuery objects for those queries. The scheme of the calling is for example:
Object1.MethodX -> Q1 := TZQuery.Create -> Q1.Open -> Q1.Next -> Call Object2.MethodY -> Q2 := TZQuery.Create -> Q2.ExecSQL -> Return to Object1.MethodX -> Q1.Next
2) A SELECT query is open concurently from a TTimer handler - do i need to use a different TZConnection object? Again, the TZQuery object is localy instanied in the handler. The call scheme could be for example:
TTimer.OnTimerHandler -> Q1 := TZQuery.Create -> Q1.Open -> Q1.Next -> DoSthWhichTakesALongTime -> TTimer.OnTimerHanlder (second run) -> Q1 := TZQuery.Create -> Q1.Open -> ... Q1.Close -> End of second run -> Q1.Next -> Q1.Close -> End of first run of timer handler.
3) Can the same TZConnection object be used from multiple threads?
To make things clear - the application is a windows service and has no gui (appart from the mandatory hidden form and timer which invokes one single method - it's pure one way communication). However it uses the database (PostgreSQL) heavily (hundreds of queries per minute). My heart is set to use persistent connections and minimize number of them, so that's basically why i'am asking
Thanks in advance for any help.
Regards,
Ondrej
TZConnection concurrency questions
Moderators: gto, EgonHugeist