开发者

inserted in multiple tables of database at a time

can we work with multiple tables of database with same connection object of database at same time .

suppose i have inserted value in table 1 and at same time also inserted value in table 2 of data base with same objec开发者_Go百科t of data base connection.

I am using sqlite database in code and getting database locked exception while commit() .


Any transaction locks the complete database. You cannot access the sqlite database during any ongoing transaction.


You need one statement per table, all using the same connection:

INSERT INTO t1(x, y, z) VALUES(1, 2, 4);
INSERT INTO t2(a, b, c) VALUES("FOO", "BAR", 2.1);

These should be inserted as a single unit of work.

If you're inserting values from the same object, you're probably doing something wrong. "Say It Once and Only Once" suggests that there shouldn't be a need to save the same value in two different tables. I'd INSERT it once and use a trigger to put it in a history table or something like that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜