create or replace FUNCTION FUNC_IS_ROW_LOCKED (v_rowid ROWID, table_name VARCHAR2)
RETURN varchar2
IS
x NUMBER;
PRAGMA AUTONOMOUS_TRANSACTION;
BEGIN
EXECUTE IMMEDIATE 'Begin
Select 1 into :x from '
|| table_name
|| ' where rowid =:v_rowid for update nowait;
Exception
When Others Then
:x:=null;
End;'
USING OUT x, v_rowid;
-- now release the lock if we got it.
ROLLBACK;
IF x = 1
THEN
RETURN 'N';
ELSIF x IS NULL
THEN
RETURN 'Y';
END IF;
END;
그리고 아래 쿼리로 결과 확인
select FUNC_IS_ROW_LOCKED (vrowid, vtablename) from dual;
출처
http://stackoverflow.com/questions/5172911/showing-rows-that-are-locked-in-oracle
댓글 없음:
댓글 쓰기