An old associate of mine wrote a quick and dirty C++ SQLite wrapper when he 
started using SQLite.  He passed me a copy of it to test out a few years ago 
and I've been using it and SQLite when I need database access.
    Somehow, up until now, I never ran across this particular problem... I 
perform a query and then, while iterating through the result set, do updates to 
the database based upon some of the things I see in that query.  It is saying 
that the database is locked and thus kicks me back.
    Is it normal that a query locks the database for writing?  Below I will 
include some of the pertinent code... I'm just a bit confused.

RS rs;

try {
    CPPSQLite::Instance()->Query(rs, "SELECT * FROM org_data");

    while (rs.MoveNext()) {
        // stuff snipped
        long balance = atol(rs.GetString("balance").c_str());
        // stuff snipped
        sprintf(buf, "UPDATE org_data SET standing = %d WHERE id = %d", 
standing, oid);
        CPPSQLite::Instance()->Execute(buf);
    }
} catch (CPPSQLiteException) {
    logs("org_update: %s", ex.ToString().c_str());
}

    Upon reaching the Execute statement it throws an exceptation saying the 
database is locked.  Is it normal for a read to lock the database for 
operating, or is his wrapper doing something odd?  If it's doing something 
wrong, I can paste the related code into another mail and hopefully someone can 
help point it out for me.  I really appreciate the time spent reading this!

Cordially,

JD Smith

Reply via email to