Hello everyone
I need to have a transaction with a select statement like so
trans = cn.beginTransaction
Insert into order table an order record
select unique order Id from order table
insert record 1 into orderdetails using the orderid
insert record 2 into orderdetails using the orderid
commit trans
I am of course experiencing record locking after my first insert. I cannot select records from the order table even though I need the inserted OrderId in order to insert into the orderitemst table.
I have tried switching the isolation level to readuncomitted on my transaction but sp_who2 still shows a block even with the readUncomitted Isolation level.
A foreign key on the orderitems table prevents me from inserting orderitems without a parent order id to prevent orphans. Is this a common transactional issue
Any help is greatly appreciated.

transactions with select statements
Eduardo D
hi,
if your "unique id" must be retrieved after insertion, that usually means it's a system generated value for your surrogate artificial key..
if this is the case, it will often be an "identity" value...
so you can just ask the instance for the last generated identity within the scope of the current batch (see in BOL the differences between SCOPE_IDENTITY, IDENT_CURRENT, and @@IDENTITY , http://msdn2.microsoft.com/en-us/library/ms190315.aspx ) using the appropriate function (SCOPE_IDENTITY is preferred
) and so you have the refereced value to be used for the successive insertions of related rows, like
and you resolved the referential problem..
regards