RE:Foreign Key / Lock Problem

"Anhaus, Thomas" <[email protected]>
Newsgroups gmane.comp.db.sapdb.general
Message-ID <[email protected]>
Jens Stier wrote :

>Hi,


>I have two tables, tblMain and tblDetail. In tbldetail is a foreign key to
>tblmain.

>if i lock a row in tblmain with:

>select * from tblmain where id=4 for update nowait

>now i can't insert a row into tbldetail with the mainid 4

>sth. like:

>insert into tbldetail (id,mainid,name) values (default, 4, 'test')


>is there any way to go around that problem?

Sorry, but there's no way. The insert into the detail table requires
a share lock for the corresponding parent row in tblmain.
This is because the parent row may have been inserted by an uncommitted
transaction which may be roll backed in the future.

Thomas

-- 
Thomas Anhaus
SAP DB, SAP Labs Berlin
[email protected]
http://www.sapdb.org/
_______________________________________________
sapdb.general mailing list
[email protected]
http://listserv.sap.com/mailman/listinfo/sapdb.general
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.