[Lazarus] SQLdb: Pseudo Transaction?

Special special at joepgen.com
Tue Jun 30 00:25:34 CEST 2020


Hi,

I am  using Lazarus 2.0.8, package SQLdb, under Win 10  (64). The 
following procedure raises an exception with message 
"TSQLite3Connection: Safety level may not be changed inside a 
transaction". This is strange, since I think there is no active 
transition in the moment when the exeption is raised.

Why this exception? How to fix? Is it maybe a bug in Lazarus 2.0.8 or in 
SQLdb?

Code:

procedure TForm1.TestButtonClick(Sender: TObject);
var XConnection:   TSQLite3Connection;
     XTransaction:  TSQLTransaction;
     XDatasource:   TDataSource;
     XQuery:        TSQLQuery;
begin
   XConnection:= TSQLite3Connection.Create(Form1);
   XTransaction:= TSQLTransaction.Create(Form1);
   XDatasource:= TDataSource.Create(Form1);
   XQuery:= TSQLQuery.Create(Form1);
   XQuery.DataBase:= XConnection;
   XQuery.Transaction:= XTransaction;
   XDatasource.DataSet:= XQuery;
   XTransaction.DataBase:= XConnection;
   XConnection.Transaction:= XTransaction;
   XConnection.DatabaseName:= ExtractFilePath (Application.ExeName) + 
'D.sqlite';
   XQuery.SQL.Text:= 'PRAGMA synchronous=OFF';
   try
     XQuery.ExecSQL;
     XTransaction.Commit;
   except
     on e: Exception do
     ShowMessage ('Exception "' + e.Message + '"')
   end;
   XQuery.Free;
   XDatasource.Free;
   XTransaction.Free;
   XConnection.Free;
end;

Regards --  Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20200630/67b127f9/attachment.html>


More information about the lazarus mailing list