我有以下选择语句,该语句在我的模式中的SQLPLUS中可以使用
select count(1) from gv$lock where id1 ='202';
但是我的函数中相同模式FN_GET_LOCK中的相同select语句在PLSQL中引发错误“表或视图不存在”
select count(1) into l_lockcnt from gv$lock where id1 = l_lock_hold;
任何想法如何使SQL语句在PLSQL中工作
此问题并非重复,因为我没有收到“权限不足错误”
答案 0 :(得分:2)
您似乎通过角色获得了SELECT
的{{1}}特权。如果是这样,那么-在命名的PL / SQL过程中将无法使用。您必须直接授予该特权给用户。
[编辑:关于角色]
一般来讲-不仅是关于角色的字典,它还是一个可供进一步研究的好资源。这是您可以用来查找该信息的示例查询:
gv$lock
让我们创建一个角色并为其授予一些特权:
SQL> select * from dictionary where lower(table_name) like '%role%';
TABLE_NAME COMMENTS
------------------------------ --------------------------------------------------
DBA_CONNECT_ROLE_GRANTEES Information regarding which users are granted CONN
ECT
DBA_ROLES All Roles which exist in the database
DBA_ROLE_PRIVS Roles granted to users and roles
DBA_SCHEDULER_JOB_ROLES All scheduler jobs in the database by database rol
e
USER_ROLE_PRIVS Roles granted to current user
ROLE_ROLE_PRIVS Roles which are granted to roles
ROLE_SYS_PRIVS System privileges granted to roles
ROLE_TAB_PRIVS Table privileges granted to roles
SESSION_ROLES Roles which the user currently has enabled.
9 rows selected.
SQL>
好的,所以-SQL> create role rl_scott_sel;
Role created.
SQL> grant select on emp to rl_scott_sel;
Grant succeeded.
SQL> grant select on bonus to rl_scott_Sel;
Grant succeeded.
SQL>
包含什么?阅读上面的注释,这似乎是一个很好的起点。
ROLE_TAB_PRIVS