On 11/9/07, Joanne Pham <[EMAIL PROTECTED]> wrote:

> I have an application to writh to database with begin transaction and end 
> transaction.
> Before end transaction another application try to connect to the database to 
> read the data and in the middle of the read of the second application
> the first application isues the end transaction. Because the read is still 
> reading the data the first application return an error message that "Couldn't 
> end the transaction ..." ( I don't remember the exactly error message) but 
> the first application couldn't "end the transaction" becuase the read of the 
> second application.

That sounds like a message returned by a wrapper you're using.

> So What you said is if the second application is connected to the database 
> while the first application is writing then the error message SQLITE_BUSY is 
> return back to application and not connect to the the database right.

When the first transaction tries to COMMIT, it will get SQLITE_BUSY
because the second transaction is still using the database file.  The
first writing transaction should simply wait a short time and try
again, in a loop.  When the second reading transaction is done, the
first will be able to COMMIT.

If you don't want concurrency like this at all, so that there can only
be one transaction using the database at any time, you can use BEGIN
EXCLUSIVE for all transactions.  If BEGIN EXCLUSIVE returns
SQLITE_BUSY, then another is using the database and this one must
wait.  If it succeeds, no others can use the database until this
transaction is done.

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to