I have a lock handle from dbms_lock.allocate_unique()
but I would like to get the Lock ID from the handle. By ID I mean the value of SYS.DBMS_ALLOCATED_LOCK.LOCKID and V$LOCK.ID1. From what I can see, it seems that the Lock Handle comprises the Lock ID concatenated with another number. However, they are both just numbers, so I don't know whether I can rely on a blunt lock ID = substr(lock_handle, 10)
.
Why I want this. I would like to be able to check for active User Defined locks in V$LOCK without having to look up the LOCKID in DBMS_ALLOCATED_LOCK by NAME (as NAME is not indexed).
I know why Oracle obfuscate the Lock ID behind the Lock Handle, but in this case I can be quite sure that the Lock ID won't be in a collision.
SYS.DBMS_ALLOCATE_LOCK
? Such object does not exist.DBMS_LOCK_ALLOCATED.NAME
is indexed.