----- Forwarded by Ben Carlyle/AU/IRSA/Rail on 09/01/2004 10:44 AM -----
Ben Carlyle 09/01/2004 09:35 AM To: "David Swigger" <[EMAIL PROTECTED]>@CORP cc: Subject: Re: [sqlite] locked - what am I doing wrong? G'day, "David Swigger" <[EMAIL PROTECTED]> 09/01/2004 12:04 AM To: <[EMAIL PROTECTED]> cc: Subject: [sqlite] locked - what am I doing wrong? > I am having a bit of a hard time understanding something: > When I am in the middle of stepping (sqlite_step) through the > results of a table query, the database is locked. Is this normal? Have > I missed something? This is discussed in Question 7 of the FAQ, but I think the first paragraph is a little misleading. I think that: "Multiple processes can have the same database open at the same time. Multiple processes can be doing a select at the same time. But only one process can be making changes to the database at once." should read: "Multiple processes can have the same database open at the same time. Multiple processes can be doing a select at the same time. But a process can't make changes to the database while any readers or other writers are active." The important thing to understand here, is that you're not stepping through a set of results that you have in memory and that were extracted from the database. You are (at least for simple queries) stepping through data that is still in the database. Because you're still actively reading the database the writer thread can't get access until your query is finished. If, instead, you want to load the whole results set into memory before stepping through them consider the sqlite_get_table_* functions. Alternatively you can collect the results into memory any way you like before stepping through the structures you've created yourself. Benjamin. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]