[Lazarus] SQLDB: how to use TSQLTransaction
Michael Van Canneyt
michael at freepascal.org
Sat Apr 11 17:03:31 CEST 2015
On Sat, 11 Apr 2015, Xiangrong Fang wrote:
> 2015-04-11 15:41 GMT+08:00 SPRL AFOR <aforsprl at gmail.com>:
>
> Michael's comments do not need further explanation
>
> If you want an Sql statement be executed immediately attach an TSqlTransaction to a DB component, attach the TSqlQuery to the transaction and enclose it between a StartTransaction and a Commit.
>
> TR.StartTransaction;
> qr.ExecSql;
> TR.Commit;
>
> The Commit matters as well
>
>
> As a matter of fact, I think yours and Michael's reply both answered part of my questions but not all. I am now clear about the meaning of RowsAffected returning value -1, but I am still not clear about WHY *sometime* I need to
> use Commit, but other times it is *not* necessary?
>
> If the rule with SQLDB is that I always need to use Commit, fine, I am perfectly fine with this rule.
The rule is: You must *always* use commit.
I cannot explain the behaviour you observed without deeper investigation, but suspect some error in your or sqlite's logic somewhere.
Happens to me also, I think I found a bug, turns out it was me being wrong all along :)
Michael.
More information about the Lazarus
mailing list