Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.0k views
in Technique[技术] by (71.8m points)

plsql - Alternative to V$LOCKED_OBJECT for finding locked tables

V$VERSION: Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production

select count(*)
INTO n_count
from V$LOCKED_OBJECT a
inner join ALL_OBJECTS o
on a.OBJECT_ID = o.OBJECT_ID
where o.OBJECT_TYPE = v_object_type
and o.OBJECT_NAME = p_table_name;

The fragment above is part of a function called during batch processing looking for table locks.

SESSION_ROLES shows the application ID has SELECT_CATALOG_ROLE. SELECT_ANY_DICTIONARY privilege was temporarily granted to the application ID to create the function.

So, we can SELECT on V$LOCKED_OBJECT, but cannot compile an object that references it without involving a different group to temporarily grant the SELECT_ANY_DICTIONARY privilege.

The issue is that deploys can make the function invalid, but the DBA cannot recompile it without the additional privilege.

Using "execute immediate" we can compile the function, but get "ORA-00942: table or view does not exist" at runtime, indicating it also expects the additional privilege. Note that when running the same "execute immediate" in a TOAD session it runs as expected. It is only running the function with it that causes the error.

Are there any other options within the application itself to determine if a table is locked?

question from:https://stackoverflow.com/questions/65928054/alternative-to-vlocked-object-for-finding-locked-tables

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...