[yunqa.de] Re: Using transactions and statements

  • From: "Radovan Antloga" <radovan.antloga@xxxxxxxx>
  • To: <yunqa@xxxxxxxxxxxxx>
  • Date: Mon, 30 Jun 2008 13:50:18 +0200

I wish it would be so simple.

I have to process a lot of data. Transaction ensure that
data for each month is processed separately. I have
actually a lot of records (more then 100 millions) to read.
For each month I have to fill (create) other tables with
results based on data read from statements.All data in
one transaction is not acceptable. So actually I have more
then one transaction (repeating steps 2 to 4). I did not want
to complicate with detail explanation in first message.

Regards,
R.Antloga

----- Original Message ----- From: "Delphi Inspiration" <delphi@xxxxxxxx>
To: <yunqa@xxxxxxxxxxxxx>
Sent: Monday, June 30, 2008 12:58 PM
Subject: [yunqa.de] Re: Using transactions and statements


Radovan Antloga wrote:

I would like to do this:

1. open statements with select sql (read data)
2. start transaction (ttDeferred)
3. do some work (create table, insert, update)
4. commit transaction
5. close statements

This will not work because I get error: SQLite error1 -
cannot commit transaction - SQL statements in progress

This error occurs because you have mixed up the order of operations. You are trying to commit (4) before you close your statements (5). Close your statements first and your commit will work just fine:

1. start transaction (ttDeferred)
2. open statements with select sql (read data)

  You "open" a statement by stepping into it.
  Just preparing a statement does not yet open it,
  so you can open it in advance if you like.

3. do some work (create table, insert, update)
4. close statements

  To "close" a statement, you can reset it
  (which allows you to reuse it) or finalize it
  (which destroys the prepared statement).

5. commit transaction

Demos you might want to look at:

* DISQLite3_Bind_Params.dpr

Ralf

_______________________________________________
Delphi Inspiration mailing list
yunqa@xxxxxxxxxxxxx
//www.freelists.org/list/yunqa



Other related posts: