[fpc-pascal] SQLdb :: Commit, Rollback, etc.

Ludo Brands ludo.brands at free.fr
Thu Dec 1 10:17:15 CET 2011


> I can't keep a transaction (server locked) all the time.
> 

What database are you using that locks up the server when a transaction is
started?

Oracle for example starts an transaction as soon as you send an executable
SQL Statement. Opening a connection starts a transaction on the server.
Therefor it is important to match this behavior on the client side and force
the use of a TSQLTransaction. Using TADOConnection doesn't change this. ADO
is just hiding it from you.  

As long as you use a transaction level that is lower or equal to Read
committed, a transaction is almost at no cost to a database server (other
than access that doesn't support transactions or mysql that uses a different
backend to support transactions).

In a client server application, datasets are local copies of (a part of) the
database and should be short lived for tables that are updated regularly.
Re-opening (re-fetching) data from such tables after a commit or rollback is
almost a must to avoid the client working with old/wrong data. If you have
datasets linked to "low or no update" tables, attach them to a different
connection. 

Ludo




More information about the fpc-pascal mailing list