[Lazarus] Problem with SQLite commit in Lazarus
Howard Lee Harkness
howard.lee.harkness at gmail.com
Wed Jul 27 04:28:58 CEST 2011
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.
I am guessing that I am missing some basic detail in the setup
somewhere, or not understanding some subtlety in the operation of
SQLite. I would greatly appreciate somebody sending me a clue on how
to deal with this. TIA!
--
Howard Lee Harkness
More information about the Lazarus
mailing list