Who is locking the row I want?

From: Johan Andersson <jna_at_astrakan.se>
Date: Tue, 3 May 94 09:11:58 +0100
Message-ID: <e2kxtALPBh107h_at_astrakan.se>


How do I identify the session that holds a lock on a specific row in a table? Is it possible in Oracle7?

I typically have a table that locks like:

	CREATE TABLE OBJEKT(
		id		number(10)
		data1		something
		data2		something
			.....
			......
	)

Before any client changes a row, it does a: 
	SELECT id FROM objekt WHERE id = nnnn FOR UPDATE NOWAIT

If someone else tries to lock the same row they get:
	ORA-00054	Resource busy and acquire with NOWAIT specified

Now, what I would like to do, is to tell Joe Smith that he can not change this specific data at this time, because John Doe at XXDept. is currently locking the resource Joe wants.

What I need is a way to identify which session is holding a specific row lock. If I have the session_id, I can get the Oracle user through V$SESSION and from there things are trivial.

I have been trying to make heads or tail of the fields in V$LOCK but without success.

Any help or insights are more than welcome.

/Johan Received on Tue May 03 1994 - 10:11:58 CEST

Original text of this message