Aha!  Now I understand what's going on.  I have been completely
missing the fact that everyone is trying to update the same table
they're reading from.  I know that's obvious to you guys, but I
completely missed that subtle fact.

   Everything makes sense now.  Thanks for your patience. :)

   -Tom 

> -----Original Message-----
> From: Martin Engelschalk [mailto:[EMAIL PROTECTED] 
> Sent: Thursday, May 12, 2005 9:53 AM
> To: sqlite-users@sqlite.org
> Subject: Re: [sqlite] database table is locked
> 
> @Thomas Briggs, Jay Sprenckle
> 
> I use the C Api described at http://www.sqlite.org/capi3ref.html.
> 
> My code seemed to work with sqlite 3.0.7, but I cannot be too sure 
> because my project is in development. It would take some time 
> to check 
> with 3.0.7
> 
> My code worked roughly like this:
> I created an update - Statement using compile().
> I created a query (simple select from one table) using compile() and 
> fetched the data using sqlite3_step()
> When i found a record i needed to update,  i bound 2 Variables using 
> sqlite3_bind_text() to the update statement, one of which was the 
> integer primary key.
> The sqlite3_exec() failed with "database table is locked".
> 
> This is a different thing to "database locked", i think.
> 
> Martin
> 
> Thomas Briggs schrieb:
> 
> >   This question seems to come up often, and I'm still confused as to
> >what problems people are having.  What APIs are you using to perform
> >these steps?  In particular, when you want to update a row, are you
> >using a prepared query that is executed multiple times, or are you
> >creating an SQL statement and executing that with 
> sqlite3_exec?  Are you
> >using 2.8 or 3.x?  Maybe the confusion on my part is due to different
> >database versions.
> >
> >   I'm confused as to why executing a query would lock the database.
> >The only thing I can think of is that the query required a 
> temp table,
> >and the creation of that temp table led to the database being locked.
> >The entire many readers/single writer concept makes no sense if
> >executing any query locks the whole database.
> >
> >   -Tom
> >
> >  
> >
> >>-----Original Message-----
> >>From: Thomas Fjellstrom [mailto:[EMAIL PROTECTED] 
> >>Sent: Thursday, May 12, 2005 7:10 AM
> >>To: sqlite-users@sqlite.org
> >>Subject: Re: [sqlite] database table is locked
> >>
> >>On May 12, 2005 04:59 am, Martin Engelschalk wrote:
> >>    
> >>
> >>>Hello,
> >>>
> >>>i open cursor on a table and retrieve rows from it.
> >>>For every row i decide whether to update it.  However, when 
> >>>      
> >>>
> >>executing
> >>    
> >>
> >>>the update I get the error "database table is locked".
> >>>My application is the only one working on the table.
> >>>Is it illegal to update a table while selecting from it or 
> >>>      
> >>>
> >>am i doing
> >>    
> >>
> >>>somethin wrong?
> >>>
> >>>Thanks,
> >>>Martin
> >>>      
> >>>
> >>Yup. you'll have to scan for updates to make, then after the 
> >>scan, make the 
> >>updates.
> >>
> >>-- 
> >>Thomas Fjellstrom
> >>[EMAIL PROTECTED]
> >>
> >>    
> >>
> 

Reply via email to