HDBC Transactions with Sqlite3

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

HDBC Transactions with Sqlite3

Tom Hawkins-2
I have HDBC running with Sqlite3, but I'm getting a SqlError due to a
locked table.  Please excuse my SQL ignorance, but what may be causing
the problem?  In SQL, are we not allowed to select, update, and delete
from a table within a single transaction?  If not, what are the rules
for transactions?

Thanks for any help!

-Tom


SELECT * FROM freeKey;
SELECT * FROM nextKey;
INSERT INTO nextKey VALUES (1);
SELECT * FROM freeKey;
SELECT * FROM nextKey;
UPDATE nextKey SET key = 2 WHERE key = 1;
SELECT * FROM freeKey;
SELECT * FROM nextKey;
UPDATE nextKey SET key = 3 WHERE key = 2;
INSERT INTO freeKey VALUES (0);
INSERT INTO freeKey VALUES (1);
SELECT * FROM freeKey;
DELETE FROM freeKey WHERE key = 0;
SqlError {seState = "", seNativeError = 1, seErrorMsg = "step:
database table is locked"}
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: HDBC Transactions with Sqlite3

John Goerzen-3
On 2006-01-13, Tom Hawkins <[hidden email]> wrote:
> I have HDBC running with Sqlite3, but I'm getting a SqlError due to a
> locked table.  Please excuse my SQL ignorance, but what may be causing
> the problem?  In SQL, are we not allowed to select, update, and delete
> from a table within a single transaction?  If not, what are the rules
> for transactions?

Sqlite3 has some restrictions that most (all?) other SQL databases don't
have.

One critical one is that, with a few exceptions, you are not allowed to
have more than one statement open on a given database simultaneously.
This has bitten me a few times as well.

I suspect that you may simply need to call finish on your statement
after you're done with your query.  This would be the most critical on
your updates (INSERT and UPDATE queries).  If you post your code, I
could probably point out specific problems.

-- John

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe