[Lazarus] Problem with SQLite commit in Lazarus

Martin Schreiber mse00000 at gmail.com
Fri Jul 29 15:29:39 CEST 2011


Am 27.07.2011 03:28, schrieb Howard Lee Harkness:
> I am migrating a small Lazarus database application from PostgreSQL to
> SQLite (PostgreSQL was overkill, and I need something which is
> zero-config and can run from a flash drive on different machines). In
> the process, I have run into several little oddities in the way that
> SQLite differs from other DBMs with which I am familiar. Most of them
> I have been able to puzzle out, but this one has me befuddled.
>
> I construct an SQL insert statement in variable sql, and then do the following:
>
>      FormDatabase.SQLite3Connection.ExecuteDirect(sql);
>      FormDatabase.SQLite3Connection.ExecuteDirect('commit');
>
> First time through, no problems. Second time through with another row
> of data, and I get an exception with a message saying there is no
> active transaction when it reaches the commit (both inserts actually
> get saved in the table, however). If I omit the commit, nothing gets
> saved to the table on exit from the program. If I add the line:
>
>      FormDatabase.SQLite3Connection.ExecuteDirect('begin');
>
> ...before the lines above, it gives an exception complaining that I
> can't nest transactions.
>
sqldb calls 'begin' when the transaction component is set to active. So 
your first 'commit' call works. The second has no 'begin'. Calling 
'begin' after the transaction component called 'begin' already fails too.

Martin




More information about the Lazarus mailing list