[Lazarus] What is a TSQLTransaction and why do I need one?

Mark Morgan Lloyd markMLl.lazarus at telemetry.co.uk
Tue Nov 23 17:01:37 CET 2010


Before anything else I'd like to say that I'm entirely familiar with 
transactions in the SQL context. However I've been having a bit of 
difficulty sorting out the relationship between a TPQConnection, 
multiple TSQLQuery, and transaction object(s).

I'm roughing out a program which I am trying to keep responsive even if 
getting updated data from the backend using SQL is slow. To do that I've 
got two TSQLQuery objects, one of which can be queried by code which 
updates the UI and the other of which will be updated the next time a 
query is to be run (at which point they'll be swapped).

Since this is strictly read-only, I can't see why I need transactions, 
but I obviously respect the judgment of whoever designed the architecture.

Am I correct in my understanding that in order to close the transaction 
I have to set Action (e.g. to caRollback) and then Active to False? It 
appears that if I don't do this the query never sees data being updated 
at the backend.

To support the two TSQLQuery objects, do I need one or two 
TSQLTransaction objects? If I have to have two TSQLTransaction objects, 
does that imply that I also have to have two TPQConnection objects?

-- 
Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]




More information about the Lazarus mailing list