[Lazarus] SQLdb: Pseudo Transaction?

Michael Van Canneyt michael at freepascal.org
Wed Jul 1 12:54:03 CEST 2020



On Wed, 1 Jul 2020, Luca Olivetti via lazarus wrote:

> El 1/7/20 a les 0:40, R.Smith via lazarus ha escrit:
>> On 2020/06/30 22:52, Special via lazarus wrote:
>>> Hi, Ryan,
>>>
>>> I followed your advice and removed XTransaction and all references to 
>>> it from TestButtonClick. But now I get an exception with the message 
>>> "Transaction not set". Any hint?
>>> Regards --  Joe
>> 
>> I'm sorry, the previous problem was SQLite-related, which I'm 
>> initimately familiar with, but this one seems to be a Lazarus DB 
>> component requirement which I'm not so much familiar with, but probably 
>> has an easy solution someone here might know about.
>> 
>> The question becomes:  How to execute a query, without a transaction 
>> being set, using SQLdb in Lazarus?
>
> I use zeos instead of sqldb. Most probably it's my fault and it could be 
> solved by doing what Michael said (use stoUseImplicit), but when I tried 
> to use sqldb with sqlite, as long as I kept the dataset open (to show 
> the data in a dbgrid) the table was locked and couldn't be modified by a 
> different thread/process.

The stoUseImplicit is one way to solve this.

An alternative was to disable the need to keep an active transaction using
TSQLQuery.Options : add sqoKeepOpenOnCommit.

see
https://www.freepascal.org/docs-html/current/fcl/sqldb/tsqlqueryoptions.html

Then you can do

Dataset.open;
MyTransaction.Commit;

And the table will not be locked.

Michael.


More information about the lazarus mailing list