Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2013-11

SQLite Vacuum & Error Cannot rollback - no transaction is active

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

mulcamd

At the end of some database maintenance where I drop several tables I want to Vacuum the SQLite database.

I use the code below and this works fine, however when I close the program I get the error:

"Project project1 raised exception class 'EDatabaseError' with message:

Cannot rollback - no transaction is active.

Question: how can I Vacuum the database and close the program without errors?

The code (which gives no error when run):

procedure TForm1.VacuumButtonClick(Sender: TObject);
begin
                SQLite3Connection.DatabaseName:='A.db';
                SQLTransaction1.Database:=SQLite3Connection;
                SQLite3Connection.Open;
                // Statement below must be issued, otherwise I get error
"cannot VACUUM from within a transaction"
                SQLite3Connection.ExecuteDirect('End Transaction');  // End
the transaction started by SQLdb
                SQLite3Connection.ExecuteDirect('Vacuum');
end;

Exit procedure which give the error message.

procedure TForm1.ExitMenuItemClick(Sender: TObject);
begin
     Application.terminate;
end;

BTW, when hitting the "break" button the cursor jumps to line 4828 " inherited Destroy;" within the "destructor TControl.Destroy;" in "control.inc".

I run on Windows 7 32 bits and use Lazarus 1.0.12 and FPC 2.6.2

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131125/b8bfb796/attachment.html>

Reply by email

K. P.
to mulcamd

As the error message indicates, do:

    SQLite3Connection.ExecuteDirect('Begin Transaction');

after the vacuum and you should be fine. Works for me.

From:
To:
Date: Mon, 25 Nov 2013 09:31:24 +0100
Subject: [Lazarus] SQLite Vacuum & Error Cannot rollback - no transaction is active

At the end of some database maintenance where I drop several tables I want to Vacuum the SQLite database. I use the code below and this works fine, however when I close the program I get the error:?Project project1 raised exception class ?EDatabaseError? with message:Cannot rollback ? no transaction is active. Question: how can I Vacuum the database and close the program without errors? The code (which gives no error when run):procedure TForm1.VacuumButtonClick(Sender: TObject);begin                SQLite3Connection.DatabaseName:='A.db';                SQLTransaction1.Database:=SQLite3Connection;                SQLite3Connection.Open;                 // Statement below must be issued, otherwise I get error ?cannot VACUUM from within a transaction?                SQLite3Connection.ExecuteDirect('End Transaction');  // End the transaction started by SQLdb                SQLite3Connection.ExecuteDirect('Vacuum');end; Exit procedure which give the error message.procedure TForm1.ExitMenuItemClick(Sender: TObject);begin     Application.terminate;end; BTW, when hitting the ?break? button the cursor jumps to line 4828 ?  inherited Destroy;? within the  ?destructor TControl.Destroy;? in ?control.inc?.I run on Windows 7 32 bits and use Lazarus 1.0.12 and FPC 2.6.2

Reply by email

mulcamd
to K. P.

Hi, thanks, it works!

Van: K. P. [mailto:]
Verzonden: dinsdag 26 november 2013 01:18
Aan:
Onderwerp: Re: [Lazarus] SQLite Vacuum & Error Cannot rollback - no transaction is active

As the error message indicates, do:

    SQLite3Connection.ExecuteDirect('Begin Transaction');

after the vacuum and you should be fine. Works for me.

_____

From:
To:
Date: Mon, 25 Nov 2013 09:31:24 +0100
Subject: [Lazarus] SQLite Vacuum & Error Cannot rollback - no transaction is active

At the end of some database maintenance where I drop several tables I want to Vacuum the SQLite database.

I use the code below and this works fine, however when I close the program I get the error:

"Project project1 raised exception class 'EDatabaseError' with message:

Cannot rollback - no transaction is active.

Question: how can I Vacuum the database and close the program without errors?

The code (which gives no error when run):

procedure TForm1.VacuumButtonClick(Sender: TObject);
begin
                SQLite3Connection.DatabaseName:='A.db';
                SQLTransaction1.Database:=SQLite3Connection;
                SQLite3Connection.Open;
                // Statement below must be issued, otherwise I get error
"cannot VACUUM from within a transaction"
                SQLite3Connection.ExecuteDirect('End Transaction');  // End
the transaction started by SQLdb
                SQLite3Connection.ExecuteDirect('Vacuum');
end;

Exit procedure which give the error message.

procedure TForm1.ExitMenuItemClick(Sender: TObject);
begin
     Application.terminate;
end;

BTW, when hitting the "break" button the cursor jumps to line 4828 " inherited Destroy;" within the "destructor TControl.Destroy;" in "control.inc".

I run on Windows 7 32 bits and use Lazarus 1.0.12 and FPC 2.6.2

-- _______________________________________________ Lazarus mailing list

http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus.freepascal.org/pipermail/lazarus/attachments/20131126/18a9a01c/attachment-0001.html>

Reply by email