[Gambas-user] sqlite Error: Query failed: cannot start a transaction within a transaction

T Lee Davidson t.lee.davidson at gmail.com
Thu Jul 11 14:54:11 CEST 2019

Without some sample code it is difficult to see exactly how you are trying to accomplish the task. But, perhaps the TRY 
instruction (http://gambaswiki.org/wiki/lang/try) might be helpful?


On 7/11/19 8:16 AM, Peter Peyotle wrote:
> hello and good day
> I use sqlite3 and get the following error: Query failed: can not start a transaction within a transaction
> The error occurs when I use sqlite Transaction. For example:
> begin transaction; create table bla bla bla; commit;
> For example, if I had already created this table once and overlooked it, I get an error. Absolutely normal.
> If I repeat the statement with a new table name, I get the error above: Query failed: can not start a transaction within a 
> transaction
> I researched but did not really find anything.
> For the test, I ended the connection to the database and restarted. No more problems.
> I then noticed that sqlite does not seem to stop the transaction when the error occurs, ignoring the "commit" and keeping the 
> transaction open.
> Or in general: If an error occurs in a statement of a transaction, the transaction is not terminated. It is stopped before the 
> commit and the transaction remains open.
> If I execute a hconn.execute ("commit;") after the failed creation of the table, every further transaction is possible.
> So far I would have solved that. But somehow unsatisfactory and not elegant.
> Now my question:
> Is there a way in sqlite to catch an error (such as the one described) and then automatically stop the transaction?
> Peter
> ----[ Gambas mailing-list is hosted by https://www.hostsharing.net ]----

More information about the User mailing list