on-lock trigger
Hi All,
I would like to get the username that has a lock on a record and append it to my custom message.
Below is my block I have on the on-lock trigger but for some reason unknown to me it returns zero records.
Now when I simulate a record lock on sqlplus I am able to get this statement to bring results.
Please help
Tx
Lebo.
declare
v_lock_message varchar2(1000);
begin
select s1.username || '@' || s1.machine
into v_lock_message
from v$lock l1, v$session s1, v$lock l2, v$session s2
where s1.sid = l1.sid
and s2.sid = l2.sid
and l1.BLOCK = 1
and l2.request > 0
and l1.id1 = l2.id1
and l2.id2 = l2.id2
and s2.username = user;
DISPLAY_MESSAGE('Customer: '||:block.customer_no||' is locked for update or delete by user '||v_lock_message, 'I', TRUE);
end;